Merge pull request #92 from LQYBill/dev

Prepare release 2.5.0
pull/8040/head
Qiuyi LI 2024-07-02 16:24:16 +02:00 committed by GitHub
commit 0fb7958db6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 630 additions and 213 deletions

View File

@ -2,10 +2,8 @@ package org.jeecg.modules.business.controller;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.business.service.ISecurityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
@ -18,13 +16,11 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class SecurityController {
@Autowired
private ISysDepartService sysDepartService;
private ISecurityService securityService;
@Autowired
private Environment env;
@GetMapping(value = "/isEmployee")
public Result<?> checkIsEmployee () {
String companyOrgCode = sysDepartService.queryCodeByDepartName(env.getProperty("company.orgName"));
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
return Result.ok(sysUser.getOrgCode().equals(companyOrgCode));
return Result.ok(securityService.checkIsEmployee());
}
}

View File

@ -1,13 +1,12 @@
package org.jeecg.modules.business.controller.admin;
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.business.service.DashboardService;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.business.service.ISecurityService;
import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
@ -28,7 +27,7 @@ import java.util.Map;
public class AdminController {
@Autowired private DashboardService dashboardService;
@Autowired private SysBaseApiImpl sysBaseApi;
@Autowired private ISysDepartService sysDepartService;
@Autowired private ISecurityService securityService;
@Autowired private Environment env;
private final Integer PERIOD = 5;
@ -52,10 +51,9 @@ public class AdminController {
@GetMapping(value = "/packageStatuses")
public Result<?> packageStatuses() {
String companyOrgCode = sysDepartService.queryCodeByDepartName(env.getProperty("company.orgName"));
boolean isEmployee = securityService.checkIsEmployee();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String orgCode = sysUser.getOrgCode();
if(!companyOrgCode.equals(orgCode)){
if(!isEmployee){
log.info("User {}, tried to access /admin/packageStatuses but is not authorized.", sysUser.getUsername());
return Result.error(403,"Not authorized to view this page.");
}

View File

@ -17,15 +17,18 @@ import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.OrderStatus;
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderResponse;
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeWarehouseRequest;
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeWarehouseRequestBody;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.*;
import org.jeecg.modules.business.domain.job.ThrottlingExecutorService;
import org.jeecg.modules.business.entity.Client;
import org.jeecg.modules.business.mapper.PlatformOrderMapper;
import org.jeecg.modules.business.service.*;
import org.jeecg.modules.business.vo.*;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@ -55,8 +58,7 @@ import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import static org.jeecg.modules.business.vo.PlatformOrderOperation.Action.CANCEL;
import static org.jeecg.modules.business.vo.PlatformOrderOperation.Action.SUSPEND;
import static org.jeecg.modules.business.vo.PlatformOrderOperation.Action.*;
/**
* @Description:
@ -82,7 +84,7 @@ public class PlatformOrderController {
@Autowired
private IShopService shopService;
@Autowired
private ISysDepartService sysDepartService;
private ISecurityService securityService;
@Autowired
private Environment env;
@ -384,10 +386,10 @@ public class PlatformOrderController {
@PostMapping("/orderManagement")
public Result<?> orderManagement(@RequestBody List<PlatformOrderOperation> orderOperations) throws IOException {
String companyOrgCode = sysDepartService.queryCodeByDepartName(env.getProperty("company.orgName"));
boolean isEmployee = securityService.checkIsEmployee();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
Client client;
if(!sysUser.getOrgCode().equals(companyOrgCode)) {
if(!isEmployee) {
client = clientService.getCurrentClient();
if (client == null) {
return Result.error(500,"Client not found. Please contact administrator.");
@ -401,31 +403,38 @@ public class PlatformOrderController {
client = clientService.getByShopId(orderOperations.get(0).getShopId());
}
long suspendCount = 0, cancelCount = 0;
long suspendCount = 0, cancelCount = 0, editCount = 0;
List<PlatformOrderOperation> ordersToSuspend = orderOperations.stream()
.filter(orderOperation -> orderOperation.getAction().equalsIgnoreCase(SUSPEND.getValue()))
.collect(Collectors.toList());
List<PlatformOrderOperation> ordersToCancel = orderOperations.stream()
.filter(orderOperation -> orderOperation.getAction().equalsIgnoreCase(CANCEL.getValue()))
.collect(Collectors.toList());
List<PlatformOrderOperation> ordersToEdit = orderOperations.stream()
.filter(orderOperation -> orderOperation.getAction().equalsIgnoreCase(EDIT.getValue()))
.collect(Collectors.toList());
for(PlatformOrderOperation orderOperation : ordersToSuspend) {
suspendCount += orderOperation.getOrderIds().split(",").length;
}
for(PlatformOrderOperation orderOperation : ordersToCancel) {
cancelCount += orderOperation.getOrderIds().split(",").length;
}
editCount = ordersToEdit.size();
log.info("{} Orders to suspend: {}", suspendCount, ordersToSuspend);
log.info("{} Orders to cancel: {}", cancelCount, ordersToCancel);
log.info("{} Orders to edit: {}", editCount, ordersToEdit);
Responses cancelResponses = new Responses();
Responses suspendResponses = new Responses();
// Cancel orders
ExecutorService cancelExecutorService = ThrottlingExecutorService.createExecutorService(DEFAULT_NUMBER_OF_THREADS,
Responses editResponses = new Responses();
ExecutorService executor = ThrottlingExecutorService.createExecutorService(DEFAULT_NUMBER_OF_THREADS,
MABANG_API_RATE_LIMIT_PER_MINUTE, TimeUnit.MINUTES);
// Cancel orders
List<CompletableFuture<Responses>> futuresCancel = ordersToCancel.stream()
.map(orderOperation -> CompletableFuture.supplyAsync(
() -> platformOrderMabangService.cancelOrders(orderOperation),
cancelExecutorService)
executor)
).collect(Collectors.toList());
List<Responses>cancelResults = futuresCancel.stream().map(CompletableFuture::join).collect(Collectors.toList());
cancelResults.forEach(res -> {
@ -437,12 +446,10 @@ public class PlatformOrderController {
// Suspend orders
ExecutorService suspendExecutorService = ThrottlingExecutorService.createExecutorService(DEFAULT_NUMBER_OF_THREADS,
MABANG_API_RATE_LIMIT_PER_MINUTE, TimeUnit.MINUTES);
List<CompletableFuture<Responses>> futuresSuspend = ordersToSuspend.stream()
.map(orderOperation -> CompletableFuture.supplyAsync(
() -> platformOrderMabangService.suspendOrder(orderOperation),
suspendExecutorService)
executor)
).collect(Collectors.toList());
List<Responses> suspendResults = futuresSuspend.stream().map(CompletableFuture::join).collect(Collectors.toList());
suspendResults.forEach(res -> {
@ -451,9 +458,49 @@ public class PlatformOrderController {
});
log.info("{}/{} orders suspended successfully.", suspendResponses.getSuccesses().size(), suspendCount);
// Edit orders
// First we clear logistic channel if order has one
List<List<String>> editOrderIds = Lists.partition(ordersToEdit.stream().map(PlatformOrderOperation::getOrderIds).collect(Collectors.toList()), 10);
List<Order> ordersWithTrackingNumber = new ArrayList<>();
List<OrderListRequestBody> requests = new ArrayList<>();
for (List<String> platformOrderIdList : editOrderIds) {
requests.add(new OrderListRequestBody().setPlatformOrderIds(platformOrderIdList));
}
List<Order> mabangOrders = platformOrderMabangService.getOrdersFromMabang(requests, executor);
for(Order mabangOrder : mabangOrders) {
if(!mabangOrder.getTrackingNumber().isEmpty()) {
ordersWithTrackingNumber.add(mabangOrder);
}
}
platformOrderMabangService.clearLogisticChannel(ordersWithTrackingNumber, executor);
List<CompletableFuture<Responses>> futuresEdit = ordersToEdit.stream()
.map(orderOperation -> CompletableFuture.supplyAsync(() -> {
ChangeWarehouseRequestBody body = new ChangeWarehouseRequestBody(orderOperation);
ChangeWarehouseRequest request = new ChangeWarehouseRequest(body);
ChangeOrderResponse response = request.send();
Responses r = new Responses();
if(response.success())
r.addSuccess(orderOperation.getOrderIds());
else
r.addFailure(orderOperation.getOrderIds());
return r;
},
executor)
).collect(Collectors.toList());
List<Responses> editResults = futuresEdit.stream().map(CompletableFuture::join).collect(Collectors.toList());
editResults.forEach(res -> {
editResponses.getSuccesses().addAll(res.getSuccesses());
editResponses.getFailures().addAll(res.getFailures());
});
log.info("{}/{} orders edited successfully.", editResponses.getSuccesses().size(), editCount);
executor.shutdown();
JSONObject result = new JSONObject();
result.put("cancelResult", cancelResponses);
result.put("suspendResult", suspendResponses);
result.put("editResult", editResponses);
// send mail
String subject = "[" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + "] Orders management report";
@ -462,12 +509,18 @@ public class PlatformOrderController {
Map<String, Object> templateModel = new HashMap<>();
templateModel.put("firstname", client.getFirstName());
templateModel.put("lastname", client.getSurname());
if(cancelCount > 0)
if(cancelCount > 0) {
templateModel.put("cancelSuccessCount", cancelResponses.getSuccesses().size() + "/" + cancelCount);
if(suspendCount > 0)
templateModel.put("cancelFailures", cancelResponses.getFailures());
}
if(suspendCount > 0) {
templateModel.put("suspendSuccessCount", suspendResponses.getSuccesses().size() + "/" + suspendCount);
templateModel.put("cancelFailures", cancelResponses.getFailures());
templateModel.put("suspendFailures", suspendResponses.getFailures());
templateModel.put("suspendFailures", suspendResponses.getFailures());
}
if(editCount > 0) {
templateModel.put("editSuccessCount", editResponses.getSuccesses().size() + "/" + editCount);
templateModel.put("editFailures", editResponses.getFailures());
}
Session session = Session.getInstance(prop, new Authenticator() {
@Override
@ -488,4 +541,22 @@ public class PlatformOrderController {
return Result.OK(result);
}
@GetMapping("/recipientInfo")
public Result<?> getRecipientInfo(@RequestParam("orderId") String platformOrderId) {
OrderListRequestBody body = new OrderListRequestBody().setPlatformOrderIds(Collections.singletonList(platformOrderId));
OrderListRawStream rawStream = new OrderListRawStream(body);
OrderListStream stream = new OrderListStream(rawStream);
List<Order> orders = stream.all();
if(orders.isEmpty()) {
return Result.error(400, "Order not found.");
}
Order order = orders.get(0);
JSONObject recipient = new JSONObject();
recipient.put("recipient", order.getRecipient());
recipient.put("phone", order.getPhone1());
recipient.put("street1", order.getAddress());
recipient.put("street2", order.getAddress2());
return Result.OK(recipient);
}
}

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.business.controller.admin;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.CaseFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -33,6 +34,8 @@ import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import static org.jeecg.common.util.SqlInjectionUtil.specialFilterContentForDictSql;
/**
* @Description: SKU
* @Author: jeecg-boot
@ -343,13 +346,53 @@ public class SkuController {
.collect(Collectors.toList())
);
}
@GetMapping("/skuListByClient")
public Result<?> skusListByClient(@RequestParam("clientId") String clientId) {
List<Sku> skus = skuService.listByClientId(clientId);
return Result.OK(skus);
}
@GetMapping("/skusByClient")
public Result<?> skusByClient(@RequestParam String clientId) {
List<SkuOrderPage> skuOrdersPage = skuService.fetchSkusByClient(clientId);
public Result<?> skusByClient(@RequestParam(name = "clientId") String clientId,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "50") Integer pageSize,
@RequestParam(name = "column", defaultValue = "erp_code") String column,
@RequestParam(name = "order", defaultValue = "ASC") String order,
@RequestParam(name = "erpCodes", required = false) String erpCodes,
@RequestParam(name = "zhNames", required = false) String zhNames,
@RequestParam(name = "enNames", required = false) String enNames
) {
String parsedColumn = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, column.replace("_dictText", ""));
String parsedOrder = order.toUpperCase();
if(!parsedOrder.equals("ASC") && !parsedOrder.equals("DESC")) {
return Result.error("Error 400 Bad Request");
}
try {
specialFilterContentForDictSql(parsedColumn);
} catch (RuntimeException e) {
return Result.error("Error 400 Bad Request");
}
List<SkuOrderPage> allSkuOrdersPage = new ArrayList<>();
List<SkuOrderPage> skuOrdersPage = new ArrayList<>();
int total = 0;
if(erpCodes != null || zhNames != null || enNames != null) {
List<String> erpCodeList = erpCodes == null ? null : Arrays.asList(erpCodes.split(","));
List<String> zhNameList = zhNames == null ? null : Arrays.asList(zhNames.split(","));
List<String> enNameList = enNames == null ? null : Arrays.asList(enNames.split(","));
allSkuOrdersPage = skuService.fetchSkusByClientWithFilters(clientId, 1, -1, parsedColumn, parsedOrder, erpCodeList, zhNameList, enNameList);
skuOrdersPage = skuService.fetchSkusByClientWithFilters(clientId, pageNo, pageSize, parsedColumn, parsedOrder, erpCodeList, zhNameList, enNameList);
}
else {
allSkuOrdersPage = skuService.fetchSkusByClient(clientId, 1, -1, parsedColumn, parsedOrder);
skuOrdersPage = skuService.fetchSkusByClient(clientId, pageNo, pageSize, parsedColumn, parsedOrder);
}
total = allSkuOrdersPage.size();
IPage<SkuOrderPage> page = new Page<>();
page.setRecords(skuOrdersPage);
page.setTotal(skuOrdersPage.size());
page.setCurrent(pageNo);
page.setSize(pageSize);
page.setTotal(total);
return Result.OK(page);
}
}

View File

@ -7,8 +7,8 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.business.entity.Client;
import org.jeecg.modules.business.entity.ClientCategory;
import org.jeecg.modules.business.service.ISecurityService;
import org.jeecg.modules.business.service.IUserClientService;
import org.jeecg.modules.system.service.ISysDepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
@ -27,7 +27,7 @@ public class UserClientController {
@Autowired
private IUserClientService userClientService;
@Autowired
private ISysDepartService sysDepartService;
private ISecurityService securityService;
@Autowired
private Environment env;
/**
@ -36,23 +36,21 @@ public class UserClientController {
*/
@GetMapping(value = "/getClient")
public Result<?> getClientByUserId() {
String companyOrgCode = sysDepartService.queryCodeByDepartName(env.getProperty("company.orgName"));
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String orgCode = loginUser.getOrgCode();
String userId = loginUser.getId();
Client client = userClientService.getClientMinInfoByUserId(userId);
if(client == null) {
if(orgCode.equals(companyOrgCode)) {
Map<String, List<Client>> internalClientList = new HashMap<>();
internalClientList.put("internal", userClientService.listClients());
return Result.OK("internal usage", internalClientList);
}
else
return Result.error(403, "Access Denied.");
boolean isEmployee = securityService.checkIsEmployee();
if(isEmployee) {
Map<String, List<Client>> internalClientList = new HashMap<>();
internalClientList.put("internal", userClientService.listClients());
return Result.OK("internal usage", internalClientList);
}
else {
String userId = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
Client client = userClientService.getClientMinInfoByUserId(userId);
if(client == null)
return Result.error(403, "Access Denied.");
Map<String, Client> clientMap = new HashMap<>();
clientMap.put("client", client);
return Result.ok(clientMap);
}
Map<String, Client> clientMap = new HashMap<>();
clientMap.put("client", client);
return Result.ok(clientMap);
}
@GetMapping(value = "/getSelfServiceClients")
public Result<?> getSelfServiceClients() {

View File

@ -5,11 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.CaseFormat;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.MutableTriple;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.dto.message.TemplateMessageDTO;
import org.jeecg.common.api.vo.Result;
@ -25,11 +25,9 @@ import org.jeecg.modules.business.mapper.PlatformOrderContentMapper;
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.service.impl.ProviderMabangServiceImpl;
import org.jeecg.modules.business.vo.*;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecg.modules.system.service.ISysDepartService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -47,7 +45,6 @@ import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.StandardSocketOptions;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.time.LocalDate;
@ -56,9 +53,11 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.jeecg.common.util.SqlInjectionUtil.specialFilterContentForDictSql;
import static org.jeecg.modules.business.entity.Invoice.InvoiceType.*;
import static org.jeecg.modules.business.entity.Task.TaskCode.SI_G;
import static org.jeecg.modules.business.entity.TaskHistory.TaskStatus.*;
import static org.jeecg.modules.business.vo.PlatformOrderFront.invoiceStatus.*;
/**
* Controller for request related to shipping invoice
@ -75,14 +74,10 @@ public class InvoiceController {
@Autowired
private IClientService clientService;
@Autowired
private ICurrencyService currencyService;
@Autowired
private ExchangeRatesMapper exchangeRatesMapper;
@Autowired
private IShopService shopService;
@Autowired
private ILogisticChannelService logisticChannelService;
@Autowired
private PlatformOrderShippingInvoiceService shippingInvoiceService;
@Autowired
private PlatformOrderMapper platformOrderMapper;
@ -93,8 +88,6 @@ public class InvoiceController {
@Autowired
private IProductService productService;
@Autowired
private ProviderMabangServiceImpl providerMabangService;
@Autowired
private IPurchaseOrderService purchaseOrderService;
@Autowired
private PurchaseOrderContentMapper purchaseOrderContentMapper;
@ -119,7 +112,7 @@ public class InvoiceController {
@Autowired
private ISysBaseAPI ISysBaseApi;
@Autowired
private ISysDepartService sysDepartService;
private ISecurityService securityService;
@Autowired
private IUserClientService userClientService;
@Autowired
@ -228,7 +221,7 @@ public class InvoiceController {
}
@PostMapping(value = "/period")
public Result<?> getValidPeriod(@RequestBody List<String> shopIDs) {
log.info("Request for valid period for shops: " + shopIDs.toString());
log.info("Request for valid period for shops: {}", shopIDs.toString());
Period period = shippingInvoiceService.getValidPeriod(shopIDs);
if (period.isValid())
return Result.OK(period);
@ -455,8 +448,7 @@ public class InvoiceController {
}
@GetMapping(value = "/preShipping/orderTime")
public Result<?> getValidOrderTimePeriod(@RequestParam("shopIds[]") List<String> shopIDs, @RequestParam("erpStatuses[]") List<Integer> erpStatuses) {
log.info("Request for valid order time period for shops: " + shopIDs.toString() +
" and erpStatuses : " + erpStatuses.toString());
log.info("Request for valid order time period for shops: {} and erpStatuses : {}", shopIDs.toString(), erpStatuses.toString());
Period period = shippingInvoiceService.getValidOrderTimePeriod(shopIDs, erpStatuses);
if (period.isValid()) {
return Result.OK(period);
@ -475,15 +467,15 @@ public class InvoiceController {
public Result<?> getOrdersBetweenOrderDates(PlatformOrder platformOrder, @RequestBody ShippingInvoiceParam param, HttpServletRequest req) {
QueryWrapper<PlatformOrder> queryWrapper = QueryGenerator.initQueryWrapper(platformOrder, req.getParameterMap());
LambdaQueryWrapper<PlatformOrder> lambdaQueryWrapper = queryWrapper.lambda();
log.info("Requesting orders for : " + param.toString());
log.info("Requesting orders for : {}", param.toString());
if (param.shopIDs() == null || param.shopIDs().isEmpty()) {
return Result.error("Missing shop IDs");
}
log.info("Specified shop IDs : " + param.shopIDs());
log.info("Specified shop IDs : {}", param.shopIDs());
lambdaQueryWrapper.in(PlatformOrder::getShopId, param.shopIDs());
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
if(param.getErpStatuses() != null) {
log.info("Specified erpStatuses : " + param.getErpStatuses());
log.info("Specified erpStatuses : {}", param.getErpStatuses());
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, param.getErpStatuses());
}
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT id FROM platform_order po WHERE po.order_time between '" + param.getStart() + "' AND '" + param.getEnd() + "'" );
@ -516,20 +508,49 @@ public class InvoiceController {
* @return A triplet of order, shipping invoice availability and purchase invoice availability
*/
@GetMapping(value = "/preShipping/ordersStatusByShops")
public Result<?> getOrdersStatusByShops(@RequestParam("shopIds") String shopIds) {
public Result<?> getOrdersStatusByShops(@RequestParam(name = "shopIds") String shopIds,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "50") Integer pageSize,
@RequestParam(name = "column", defaultValue = "order_time") String column,
@RequestParam(name = "order", defaultValue = "ASC") String order) {
log.info("User : {} is requesting uninvoiced orders for shops : [{}]",
((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername(),
shopIds);
String parsedColumn = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, column.replace("_dictText",""));
String parsedOrder = order.toUpperCase();
if(!parsedOrder.equals("ASC") && !parsedOrder.equals("DESC")) {
return Result.error("Error 400 Bad Request");
}
try {
specialFilterContentForDictSql(parsedColumn);
}
catch (RuntimeException e) {
e.printStackTrace();
return Result.error("Error 400 : Bad Request");
}
// checking shipping data availability
List<String> shopIdList = Arrays.asList(shopIds.split(","));
// fetch order that can be invoice either by shipping or purchase or both
List<PlatformOrder> orders = platformOrderService.findUninvoicedOrdersByShopForClient(shopIdList, Collections.singletonList(1));
// fetch order that can be invoiced either by shipping or purchase or both
List<PlatformOrder> allOrders = platformOrderService.findUninvoicedOrdersByShopForClient(shopIdList, Collections.singletonList(1), parsedColumn, parsedOrder, 1, -1);
int total = allOrders.size();
List<PlatformOrder> orders = platformOrderService.findUninvoicedOrdersByShopForClient(shopIdList, Collections.singletonList(1), parsedColumn, parsedOrder, pageNo, pageSize);
// LinkedList<PlatformOrder> sortedOrders = orders.stream().sorted(Comparator.comparing(PlatformOrder::getOrderTime)).collect(Collectors.toCollection(LinkedList::new));
if(orders.isEmpty())
return Result.OK("No order to invoice.");
Map<String, String> shops = shopService.listByIds(shopIdList).stream().collect(Collectors.toMap(Shop::getId, Shop::getName));
List<String> orderIds = orders.stream().map(PlatformOrder::getId).collect(Collectors.toList());
Map<PlatformOrder, List<PlatformOrderContent>> orderContentMap = platformOrderService.fetchOrderData(orderIds);
// some orders may not have content, so we have to re-add them
if(orderIds.size() != orderContentMap.size()) {
List<String> orderIdsInMap = orderContentMap.keySet().stream().map(PlatformOrder::getId).collect(Collectors.toList());
List<String> orderIdsWithoutContent = orderIds.stream().filter(id -> !orderIdsInMap.contains(id)).collect(Collectors.toList());
List<PlatformOrder> ordersWithoutContent = platformOrderService.listByIds(orderIdsWithoutContent);
Map<PlatformOrder, List<PlatformOrderContent>> orderContentMapWithoutContent = new HashMap<>();
for(PlatformOrder po : ordersWithoutContent) {
orderContentMapWithoutContent.put(po, new ArrayList<>());
}
orderContentMap.putAll(orderContentMapWithoutContent);
}
Map<String, String> errorMapToOrderId = new HashMap<>();
List<PlatformOrderFront> orderFronts = new ArrayList<>();
@ -541,8 +562,20 @@ public class InvoiceController {
//rename shop id by shop name to prevent it to leak in front
orderFront.setShopId(shops.get(orderFront.getShopId()));
// set default value of shipping and purchase availability
orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Available.code);
orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Available.code);
orderFront.setShippingAvailable(Available.code);
orderFront.setPurchaseAvailable(Available.code);
if(entry.getValue().isEmpty()) {
if(!errorMapToOrderId.containsKey(entry.getKey().getPlatformOrderId()))
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : order has no content : " + entry.getKey().getPlatformOrderId());
else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and has no content");
orderFront.setShippingAvailable(Unavailable.code);
orderFront.setPurchaseAvailable(Unavailable.code);
orderFronts.add(orderFront);
continue;
}
List<String> skuIds = entry.getValue().stream().map(PlatformOrderContent::getSkuId).distinct().collect(Collectors.toList());
// finds the first sku that isn't in db
List<Sku> skuIdsFound = skuService.listByIds(skuIds);
@ -552,8 +585,9 @@ public class InvoiceController {
else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing one or more sku in db");
orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
orderFront.setShippingAvailable(Unavailable.code);
orderFront.setPurchaseAvailable(Unavailable.code);
continue;
}
if(entry.getKey().getShippingInvoiceNumber() == null) {
@ -563,7 +597,7 @@ public class InvoiceController {
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing logistic channel for order : " + entry.getKey().getPlatformOrderId());
else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing logistic channel");
orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
orderFront.setShippingAvailable(Unavailable.code);
}
// finds the first product with missing weight
String missingWeightProductId = productService.searchFirstEmptyWeightProduct(skuIds);
@ -572,7 +606,7 @@ public class InvoiceController {
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing one or more weight for order : " + entry.getKey().getPlatformOrderId());
else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing weight");
orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
orderFront.setShippingAvailable(Unavailable.code);
}
}
if(entry.getKey().getPurchaseInvoiceNumber() == null) {
@ -583,7 +617,7 @@ public class InvoiceController {
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing one or more sku price for order : " + entry.getKey().getPlatformOrderId());
else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing one or more sku price");
orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
orderFront.setPurchaseAvailable(Unavailable.code);
}
}
@ -600,18 +634,18 @@ public class InvoiceController {
if(entry.getKey().getPurchaseInvoiceNumber() != null) {
PurchaseOrder purchase = purchaseOrderService.getPurchaseByInvoiceNumber(entry.getKey().getPurchaseInvoiceNumber());
if(purchase.getPaidAmount().compareTo(BigDecimal.ZERO) == 0)
orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Invoiced.code);// invoiced
orderFront.setPurchaseAvailable(Invoiced.code);// invoiced
else
orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Paid.code);// paid
orderFront.setPurchaseAvailable(Paid.code);// paid
}
// set shipping order status (-1 = unavailable, 0 = available, 1 = invoiced, 2 = paid)
if(entry.getKey().getShippingInvoiceNumber() != null) {
ShippingInvoice shippingInvoice = iShippingInvoiceService.getShippingInvoice(entry.getKey().getShippingInvoiceNumber());
if(shippingInvoice.getPaidAmount().compareTo(BigDecimal.ZERO) == 0) {
orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Invoiced.code); // invoiced
orderFront.setShippingAvailable(Invoiced.code); // invoiced
}
else {
orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Paid.code); // paid
orderFront.setShippingAvailable(Paid.code); // paid
}
}
orderFronts.add(orderFront);
@ -646,7 +680,9 @@ public class InvoiceController {
IPage<PlatformOrderFront> page = new Page<>();
page.setRecords(orderFronts);
page.setTotal(orderFronts.size());
page.setSize(pageSize);
page.setCurrent(pageNo);
page.setTotal(total);
return Result.OK(page);
}
@ -661,11 +697,11 @@ public class InvoiceController {
public Result<?> getOrdersBetweenDates(PlatformOrder platformOrder, @RequestBody ShippingInvoiceParam param, HttpServletRequest req) {
QueryWrapper<PlatformOrder> queryWrapper = QueryGenerator.initQueryWrapper(platformOrder, req.getParameterMap());
LambdaQueryWrapper<PlatformOrder> lambdaQueryWrapper = queryWrapper.lambda();
log.info("Requesting orders for : " + param.toString());
log.info("Requesting orders for : {}", param.toString());
if (param.shopIDs() == null || param.shopIDs().isEmpty()) {
return Result.error("Missing shop IDs");
}
log.info("Specified shop IDs : " + param.shopIDs());
log.info("Specified shop IDs : {}", param.shopIDs());
lambdaQueryWrapper.in(PlatformOrder::getShopId, param.shopIDs());
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT id FROM platform_order po WHERE po.erp_status = '3' AND po.shipping_time between '" + param.getStart() + "' AND '" + param.getEnd() + "'" );
@ -897,14 +933,20 @@ public class InvoiceController {
* @param param Parameters for creating a pre-shipping invoice
* @return One ShippingFeesEstimation
*/
@PostMapping(value = "/selfEstimateFees")
public Result<?> getPurchaseFeesEstimateByOrders(@RequestBody ShippingInvoiceOrderParam param) {
@PostMapping(value = "/completeFeesEstimation")
public Result<?> getCompleteFeesEstimation(@RequestBody ShippingInvoiceOrderParam param) {
boolean isEmployee = securityService.checkIsEmployee();
String currency = clientService.getById(param.clientID()).getCurrency();
List<PlatformOrder> orders = platformOrderMapper.fetchByIds(param.orderIds());
Map<String, List<PlatformOrder>> ordersMapByShop = orders.stream().collect(Collectors.groupingBy(PlatformOrder::getShopId));
Map<String, Estimation> estimationsByShop = new HashMap<>();
for(Map.Entry<String, List<PlatformOrder>> entry : ordersMapByShop.entrySet()) {
String shopId = entry.getKey();
String shop;
if(!isEmployee)
shop = shopService.getNameById(shopId);
else
shop = shopService.getCodeById(shopId);
List<String> orderIds = entry.getValue().stream().map(PlatformOrder::getId).collect(Collectors.toList());
ShippingInvoiceOrderParam finalParam = new ShippingInvoiceOrderParam(param.clientID(), orderIds, param.getType());
List<String> errorMessages = new ArrayList<>();
@ -912,6 +954,7 @@ public class InvoiceController {
finalParam.orderIds(), errorMessages);
if(shippingFeesEstimations.isEmpty())
return Result.OK("No estimation found.");
String internalCode = shippingFeesEstimations.get(0).getCode();
// purchase estimation
// only calculate purchase estimation if products are not available and purchaseInvoiceNumber is null, else it's already been paid
@ -921,25 +964,37 @@ public class InvoiceController {
&& order.getPurchaseInvoiceNumber() == null
&& order.getVirtualProductAvailable().equals("0"))
.map(PlatformOrder::getId).collect(Collectors.toList());
BigDecimal shippingFeesEstimation = BigDecimal.ZERO;
BigDecimal purchaseEstimation = BigDecimal.ZERO;
int ordersToProccess = 0;
int processedOrders = 0;
boolean isCompleteInvoiceReady = true;
for(ShippingFeesEstimation estimation: shippingFeesEstimations) {
shippingFeesEstimation = shippingFeesEstimation.add(estimation.getDueForProcessedOrders());
ordersToProccess += estimation.getOrdersToProcess();
processedOrders += estimation.getProcessedOrders();
}
if(!orderIdsWithProductUnavailable.isEmpty()) {
List<PlatformOrderContent> orderContents = platformOrderContentMap.fetchOrderContent(orderIdsWithProductUnavailable);
List<String> skuIds = orderContents.stream().map(PlatformOrderContent::getSkuId).collect(Collectors.toList());
List<SkuPrice> skuPrices = platformOrderContentMap.searchSkuPrice(skuIds);
BigDecimal exchangeRateEurToRmb = exchangeRatesMapper.getLatestExchangeRate("EUR", "RMB");
if(skuPrices.size() != skuIds.size()) {
isCompleteInvoiceReady = false;
errorMessages.add("Some sku prices are missing.");
for(SkuPrice skuPrice : skuPrices) {
if(skuPrice.getPrice() == null) {
isCompleteInvoiceReady = false;
errorMessages.add("Some sku prices are missing.");
break;
}
}
for(PlatformOrderContent content : orderContents){
for (SkuPrice skuPrice : skuPrices) {
if(content.getSkuId().equals(skuPrice.getSkuId())) {
purchaseEstimation = purchaseEstimation.add(skuPrice.getPrice(content.getQuantity(), exchangeRateEurToRmb));
BigDecimal price = skuPrice.getPrice(content.getQuantity(), exchangeRateEurToRmb);
price = price.multiply(new BigDecimal(content.getQuantity()));
purchaseEstimation = purchaseEstimation.add(price);
break;
}
}
}
@ -952,9 +1007,9 @@ public class InvoiceController {
purchaseEstimation = purchaseEstimation.multiply(exchangeRate).setScale(2, RoundingMode.CEILING);
shippingFeesEstimation = shippingFeesEstimation.multiply(exchangeRate).setScale(2, RoundingMode.CEILING);
}
log.info("Purchase Fee " + currency + " : " + purchaseEstimation);
log.info("Shipping Fee " + currency + " : " + shippingFeesEstimation);
estimationsByShop.put(shopId, new Estimation(shippingFeesEstimation, purchaseEstimation, currency, errorMessages, Collections.singletonList(shopId), "", "", isCompleteInvoiceReady));
log.info("Purchase Fee {} : {}", currency, purchaseEstimation);
log.info("Shipping Fee {} : {}", currency, shippingFeesEstimation);
estimationsByShop.put(shopId, new Estimation(internalCode, ordersToProccess, processedOrders, shippingFeesEstimation, purchaseEstimation, currency, errorMessages, shop, Collections.singletonList(shopId), "", "", isCompleteInvoiceReady, orderIds));
}
// return list of estimation by shop
return Result.ok(estimationsByShop);
@ -962,9 +1017,8 @@ public class InvoiceController {
@GetMapping(value = "/checkInvoiceValidity")
public Result<?> checkInvoiceValidity(@RequestParam("invoiceNumber") String invoiceNumber) {
String companyOrgCode = sysDepartService.queryCodeByDepartName(env.getProperty("company.orgName"));
boolean isEmployee = securityService.checkIsEmployee();
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String orgCode = sysUser.getOrgCode();
String email = sysUser.getEmail();
String invoiceID;
String customerFullName;
@ -985,7 +1039,7 @@ public class InvoiceController {
client = clientService.getClientFromPurchase(invoiceID);
customerFullName = client.fullName();
String destEmail;
if(!orgCode.equals(companyOrgCode)) {
if(!isEmployee) {
log.info("User {} is trying to access invoice {} from client {}", sysUser.getUsername(), invoiceNumber, client.getInternalCode());
Client userClient = userClientService.getClientByUserId(sysUser.getId());

View File

@ -93,10 +93,14 @@ public class TransactionController {
List<String> errorMessages = new ArrayList<>();
List<String> shopIds = shopService.listIdByClient(clientId);
List<PlatformOrder> shippingOrders = platformOrderService.findUninvoicedShippingOrdersByShopForClient(shopIds, Arrays.asList(1,2,3));
List<String> orderIds = shippingOrders.stream().map(PlatformOrder::getId).collect(Collectors.toList());
Date startDate = null;
Date endDate = null;
List<ShippingFeesEstimation> shippingFeesEstimations;
BigDecimal shippingFeesEstimation = BigDecimal.ZERO;
String internalCode = "";
int ordersToProcess = 0;
int processedOrders = 0;
if(!shippingOrders.isEmpty()) {
startDate = shippingOrders.stream().map(PlatformOrder::getOrderTime).min(Date::compareTo).get();
endDate = shippingOrders.stream().map(PlatformOrder::getOrderTime).max(Date::compareTo).get();
@ -109,7 +113,10 @@ public class TransactionController {
shippingFeesEstimations = factory.getEstimations(clientId, shippingOrderIds, errorMessages);
for (ShippingFeesEstimation estimation : shippingFeesEstimations) {
shippingFeesEstimation = shippingFeesEstimation.add(estimation.getDueForProcessedOrders());
ordersToProcess += estimation.getOrdersToProcess();
processedOrders += estimation.getProcessedOrders();
}
internalCode = shippingFeesEstimations.get(0).getCode();
}
// purchase estimation
@ -160,8 +167,8 @@ public class TransactionController {
shippingFeesEstimation = shippingFeesEstimation.multiply(exchangeRate).setScale(2, RoundingMode.CEILING);
}
log.info("Purchase Fee " + currency + " : " + purchaseEstimation);
log.info("Shipping Fee " + currency + " : " + shippingFeesEstimation);
log.info("Purchase Fee {} : {}", currency, purchaseEstimation);
log.info("Shipping Fee {} : {}", currency, shippingFeesEstimation);
// system notification
String errors = SECTION_START;
int max_entries = 100;
@ -184,6 +191,6 @@ public class TransactionController {
ISysBaseApi.sendTemplateAnnouncement(message);
}
}
return Result.ok(new Estimation(shippingFeesEstimation, purchaseEstimation, currency, errorMessages, shopIds, new DateTime(startDate).toString(), new DateTime(endDate).toString(), isCompleteInvoiceReady));
return Result.ok(new Estimation(internalCode, ordersToProcess, processedOrders, shippingFeesEstimation, purchaseEstimation, currency, errorMessages,null, shopIds, new DateTime(startDate).toString(), new DateTime(endDate).toString(), isCompleteInvoiceReady, orderIds));
}
}

View File

@ -7,6 +7,7 @@ import lombok.Setter;
import org.jeecg.modules.business.domain.api.mabang.RequestBody;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.Order;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.OrderItem;
import org.jeecg.modules.business.vo.PlatformOrderOperation;
import java.util.function.Function;
@ -20,6 +21,7 @@ public class ChangeWarehouseRequestBody implements RequestBody {
private String recipient;
private String street1;
private String street2;
private String phone;
public ChangeWarehouseRequestBody(Order order, String warehouseName) {
this.platformOrderId = order.getPlatformOrderId();
@ -27,8 +29,16 @@ public class ChangeWarehouseRequestBody implements RequestBody {
this.recipient = order.getRecipient();
this.street1 = order.getAddress();
this.street2 = order.getAddress2();
this.phone = order.getPhone1();
this.order = order;
}
public ChangeWarehouseRequestBody(PlatformOrderOperation order) {
this.setOrderId(order.getOrderIds());
this.recipient = order.getRecipient();
this.street1 = order.getStreet1();
this.street2 = order.getStreet2();
this.phone = order.getPhone();
}
@Override
public String api() {
@ -43,6 +53,9 @@ public class ChangeWarehouseRequestBody implements RequestBody {
putNonNull(json, "buyerName", recipient);
putNonNull(json, "street1", street1);
putNonNull(json, "street2", street2);
putNonNull(json, "phone1", phone);
if(order == null)
return json;
if(order.getOrderItems() != null && !order.getOrderItems().isEmpty()) {
for(OrderItem orderItem : order.getOrderItems()) {
if(!isSkuValidFormat(orderItem.getErpCode()))
@ -72,4 +85,8 @@ public class ChangeWarehouseRequestBody implements RequestBody {
json.put(key, mapper.apply(value));
}
}
public void setOrderId(String orderId) {
// clean string from spaces, comas and quotes
this.platformOrderId = orderId.replaceAll("[,\\s\"]", "");
}
}

View File

@ -10,6 +10,7 @@ import org.jeecg.modules.business.domain.api.mabang.getorderlist.*;
import org.jeecg.modules.business.domain.api.mabang.orderDoOrderAbnormal.OrderSuspendRequest;
import org.jeecg.modules.business.domain.api.mabang.orderDoOrderAbnormal.OrderSuspendRequestBody;
import org.jeecg.modules.business.domain.api.mabang.orderDoOrderAbnormal.OrderSuspendResponse;
import org.jeecg.modules.business.service.IPlatformOrderMabangService;
import org.jeecg.modules.business.service.IPlatformOrderService;
import org.jeecg.modules.business.vo.Responses;
import org.quartz.Job;
@ -18,14 +19,12 @@ import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.Normalizer;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList;
@ -34,6 +33,8 @@ import static java.util.stream.Collectors.toList;
public class ChangeWarehouseJob implements Job {
@Autowired
private IPlatformOrderService platformOrderService;
@Autowired
private IPlatformOrderMabangService platformOrderMabangService;
private static final Integer DEFAULT_NUMBER_OF_DAYS = 5;
private static final Integer DEFAULT_NUMBER_OF_THREADS = 10;
@ -179,14 +180,9 @@ public class ChangeWarehouseJob implements Job {
}
public void replaceOrdersAccents(List<Order> orders) {
for(Order order: orders) {
order.setRecipient(stripAccents(order.getRecipient()));
order.setAddress(stripAccents(order.getAddress()));
order.setAddress2(stripAccents(order.getAddress2()));
order.setRecipient(platformOrderMabangService.stripAccents(order.getRecipient()));
order.setAddress(platformOrderMabangService.stripAccents(order.getAddress()));
order.setAddress2(platformOrderMabangService.stripAccents(order.getAddress2()));
}
}
public String stripAccents(String input) {
input = Normalizer.normalize(input, Normalizer.Form.NFD);
input = input.replaceAll("[^\\p{ASCII}]", "");
return input;
}
}

View File

@ -9,6 +9,7 @@ import org.codehaus.jettison.json.JSONObject;
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.*;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.*;
import org.jeecg.modules.business.entity.PlatformOrder;
import org.jeecg.modules.business.service.IPlatformOrderMabangService;
import org.jeecg.modules.business.service.IPlatformOrderService;
import org.quartz.Job;
import org.quartz.JobDataMap;
@ -34,6 +35,8 @@ public class RemoveVirtualProductJob implements Job {
@Autowired
private IPlatformOrderService platformOrderService;
@Autowired
private IPlatformOrderMabangService platformOrderMabangService;
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
@ -88,28 +91,8 @@ public class RemoveVirtualProductJob implements Job {
for (List<String> platformOrderIdList : platformOrderIdLists) {
requests.add(new OrderListRequestBody().setPlatformOrderIds(platformOrderIdList));
}
List<Order> mabangOrders = new ArrayList<>();
ExecutorService executor = Executors.newFixedThreadPool(DEFAULT_NUMBER_OF_THREADS);
List<CompletableFuture<Boolean>> futures = requests.stream()
.map(request -> CompletableFuture.supplyAsync(() -> {
boolean success = false;
try {
OrderListRawStream rawStream = new OrderListRawStream(request);
OrderListStream stream = new OrderListStream(rawStream);
List<Order> orders = stream.all();
mabangOrders.addAll(orders);
success = !orders.isEmpty();
} catch (RuntimeException e) {
log.error("Error communicating with MabangAPI", e);
}
return success;
}, executor))
.collect(Collectors.toList());
List<Boolean> results = futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
long nbSuccesses = results.stream().filter(b -> b).count();
log.info("{}/{} requests have succeeded.", nbSuccesses, requests.size());
log.info("{}/{} mabang orders have been retrieved.", mabangOrders.size(), platformOrderIds.size());
List<Order> mabangOrders = platformOrderMabangService.getOrdersFromMabang(requests, executor);
log.info("Constructing virtual SKU removal requests");
List<Order> ordersWithLogistic = new ArrayList<>();
@ -139,17 +122,7 @@ public class RemoveVirtualProductJob implements Job {
log.info("{} virtual SKU removal requests to be sent to MabangAPI", removeSkuRequests.size());
// First we delete the logistic channel names, otherwise we can't delete virtual skus
List<CompletableFuture<Boolean>> clearLogisticFutures = ordersWithLogistic.stream()
.map(orderWithLogistic -> CompletableFuture.supplyAsync(() -> {
ClearLogisticRequestBody body = new ClearLogisticRequestBody(orderWithLogistic.getPlatformOrderId());
ClearLogisticRequest request = new ClearLogisticRequest(body);
ClearLogisticResponse response = request.send();
return response.success();
}, executor))
.collect(Collectors.toList());
List<Boolean> logisticResults = clearLogisticFutures.stream().map(CompletableFuture::join).collect(Collectors.toList());
long logisticClearSuccessCount = logisticResults.stream().filter(b -> b).count();
log.info("{}/{} logistic channel names cleared successfully.", logisticClearSuccessCount, ordersWithLogistic.size());
platformOrderMabangService.clearLogisticChannel(ordersWithLogistic, executor);
List<CompletableFuture<Boolean>> removeSkuFutures = removeSkuRequests.stream()
.map(removeSkuRequestBody -> CompletableFuture.supplyAsync(() -> {
@ -164,8 +137,8 @@ public class RemoveVirtualProductJob implements Job {
return success;
}, executor))
.collect(Collectors.toList());
results = removeSkuFutures.stream().map(CompletableFuture::join).collect(Collectors.toList());
nbSuccesses = results.stream().filter(b -> b).count();
List<Boolean> results = removeSkuFutures.stream().map(CompletableFuture::join).collect(Collectors.toList());
long nbSuccesses = results.stream().filter(b -> b).count();
log.info("{}/{} virtual SKU removal requests have succeeded.", nbSuccesses, removeSkuRequests.size());
}
}

View File

@ -102,39 +102,6 @@ public class ShippingInvoice implements Serializable {
@ApiModelProperty(value = "currency ID")
private java.lang.String currencyId;
public void setID(String id) {
this.id = id;
}
public void setCreateBy(String user) {
this.createBy = user;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public void setClientI(String clientId) {
this.clientId = clientId;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public void setTotalAmount(java.math.BigDecimal totalAmount) {
this.totalAmount = totalAmount;
}
public void setDiscountAmount(java.math.BigDecimal discountAmount) {
this.discountAmount = discountAmount;
}
public void setFinalAmount(java.math.BigDecimal finalAmount) {
this.finalAmount = finalAmount;
}
public void setPaidAmount(java.math.BigDecimal paidAmount) {
this.paidAmount = paidAmount;
}
public ShippingInvoice() {
// this.id = null;
// this.createBy = null;

View File

@ -14,10 +14,7 @@ import org.jeecg.modules.business.vo.clientPlatformOrder.section.OrderQuantity;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Description:
@ -194,7 +191,8 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
List<PlatformOrder> findUninvoicedShippingOrdersByShopForClient(@Param("shopIds") List<String> shopIds, @Param("erpStatuses") List<Integer> erpStatuses);
List<PlatformOrder> fetchUninvoicedPurchaseOrdersByShopForClient(@Param("shopIds") List<String> shopIds, @Param("erpStatuses") List<Integer> erpStatuses);
List<PlatformOrder> findUninvoicedOrdersByShopForClient(@Param("shopIds") List<String> shopIds, @Param("erpStatuses") List<Integer> erpStatuses);
List<PlatformOrder> findUninvoicedOrdersByShopForClient(@Param("shopIds") List<String> shopIds, @Param("erpStatuses") List<Integer> erpStatuses,
@Param("column") String column, @Param("order") String order, @Param("offset") Integer offset, @Param("size") Integer pageSize);
List<String> findUninvoicedOrderIdsByShopForClient(@Param("shopIds") List<String> shopIds, @Param("erpStatuses") List<Integer> erpStatuses);
List<PlatformOrder> fetchEmptyLogisticChannelOrders(@Param("startDate") String startDate,@Param("endDate") String endDate);

View File

@ -24,4 +24,8 @@ public interface ShopMapper extends BaseMapper<Shop> {
List<String> selectShopIdByClient(@Param("clientID") String clientID);
List<String> getShopIdsByClientAndType(@Param("clientIds") List<String> clientIds, @Param("type") String clientType);
String getNameById(@Param("shopId") String shopId);
String getCodeById(@Param("shopId") String shopId);
}

View File

@ -54,7 +54,8 @@ public interface SkuMapper extends BaseMapper<Sku> {
List<SkuQuantity> getSkuQuantitiesFromOrderIds(@Param("orderIds") List<String> orderIds);
List<SkuOrderPage> fetchSkusByClient(@Param("clientId") String clientId);
List<SkuOrderPage> fetchSkusByClient(@Param("clientId") String clientId, @Param("offset") Integer offset, @Param("size") Integer pageSize, @Param("column") String column, @Param("order") String order);
List<SkuOrderPage> fetchSkusByClientWithFilters(@Param("clientId") String clientId, @Param("offset") Integer offset, @Param("size") Integer pageSize, @Param("column") String column, @Param("order") String order, @Param("erpCodes") String erpCodesRegex, @Param("zhNames") String zhNamesRegex, @Param("enNames") String enNamesRegex);
String getIdFromErpCode(@Param("erpCode") String erpCode);
@ -65,4 +66,6 @@ public interface SkuMapper extends BaseMapper<Sku> {
void updateBatchStockByIds(@Param("skus") List<Sku> skuToUpdate);
List<SkuOrderPage> getInventoryByInvoiceNumber(@Param("invoiceNumber") String invoiceNumber);
List<Sku> listByClientId(@Param("clientId") String clientId);
}

View File

@ -334,7 +334,7 @@
</foreach>);
</update>
<select id="searchSkuPrice" resultType="org.jeecg.modules.business.entity.SkuPrice">
SELECT * FROM sku_price
SELECT DISTINCT * FROM sku_price
WHERE sku_id IN
<foreach collection="skuIds" separator="," open="(" close=")" index="index" item="skuId">
#{skuId}

View File

@ -649,7 +649,7 @@
</foreach>;
</select>
<select id="findUninvoicedOrdersByShopForClient" resultType="org.jeecg.modules.business.entity.PlatformOrder">
SELECT *
SELECT id, order_time, platform_order_number
FROM platform_order
WHERE erp_status IN
<foreach
@ -675,7 +675,12 @@
item="shopId"
>
#{shopId}
</foreach>;
</foreach>
ORDER BY ${column} ${order}
<if test="size != -1">
LIMIT #{offset}, #{size}
</if>
;
</select>
<insert id="insertPlatformOrdersArchives" parameterType="list">
INSERT INTO platform_order_delete(id, create_by,

View File

@ -35,4 +35,14 @@
</foreach>
AND cc.name = #{type}
</select>
<select id="getNameById" resultType="java.lang.String">
SELECT name
FROM shop
WHERE id = #{shopId};
</select>
<select id="getCodeById" resultType="java.lang.String">
SELECT erp_code
FROM shop
WHERE id = #{shopId};
</select>
</mapper>

View File

@ -160,7 +160,7 @@
JOIN shop s ON po.shop_id = s.id
JOIN client c ON s.owner_id = c.id
WHERE c.id = #{clientId}
AND po.erp_status IN ('1','2')
AND po.erp_status IN ('1','2')
AND poc.erp_status IN ('1','2')
GROUP BY sku_id
)
@ -208,7 +208,92 @@
LEFT JOIN sales_42 s42 ON s.id = s42.sku_id
LEFT JOIN sales_7 s7 ON s.id = s7.sku_id
LEFT JOIN qtyInOrdersNotShipped ON s.id = qtyInOrdersNotShipped.ID
WHERE client_sku.client_id = #{clientId};
WHERE client_sku.client_id = #{clientId}
ORDER BY ${column} ${order}
<if test="size != -1">
LIMIT #{offset}, #{size}
</if>
;
</select>
<select id="fetchSkusByClientWithFilters" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
WITH qtyInOrdersNotShippedCTE AS (
SELECT sku_id as ID, SUM(quantity) AS quantity
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
JOIN client c ON s.owner_id = c.id
WHERE c.id = #{clientId}
AND po.erp_status IN ('1','2')
AND poc.erp_status IN ('1','2')
GROUP BY sku_id
)
SELECT s.id,
s.erp_code,
p.en_name as productEn,
p.zh_name as product,
s.purchasing_amount,
s.available_amount,
qtyInOrdersNotShippedCTE.quantity as qtyInOrdersNotShipped,
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock,
s.image_source,
s.service_fee,
IF(sp.price_rmb IS NULL, sp.price,
(
ROUND(
sp.price_rmb /
(SELECT rate
FROM exchange_rates
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
ORDER BY create_time DESC LIMIT 1)
,2)
)
) as sku_price,
sp.threshold as discount_moq,
IF(sp.price_rmb IS NULL, sp.discounted_price,
(
ROUND(
sp.discounted_price_rmb /
(SELECT rate
FROM exchange_rates
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
ORDER BY create_time DESC LIMIT 1)
,2)
)
) as discounted_price,
s7.quantity as sales_last_week,
s28.quantity as sales_four_weeks,
s42.quantity as sales_six_weeks
FROM sku s
JOIN client_sku ON s.id = client_sku.sku_id
JOIN product p ON s.product_id = p.id
LEFT JOIN sku_current_price sp ON s.id = sp.sku_id
LEFT JOIN sales_28 s28 ON s.id = s28.sku_id
LEFT JOIN sales_42 s42 ON s.id = s42.sku_id
LEFT JOIN sales_7 s7 ON s.id = s7.sku_id
LEFT JOIN qtyInOrdersNotShippedCTE ON s.id = qtyInOrdersNotShippedCTE.ID
WHERE client_sku.client_id = #{clientId}
AND (
<if test="erpCodes != ''">
s.erp_code REGEXP #{erpCodes}
</if>
<if test="zhNames != ''">
<if test="erpCodes != ''">
AND
</if>
p.zh_name REGEXP #{zhNames}
</if>
<if test="enNames != ''">
<if test="erpCodes != '' || zhNames != ''">
AND
</if>
p.en_name REGEXP #{enNames}
</if>
)
ORDER BY ${column} ${order}
<if test="size != -1">
LIMIT #{offset}, #{size}
</if>
;
</select>
<select id="getInventoryByInvoiceNumber" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
WITH skusFromInvoice AS (
@ -316,4 +401,14 @@
#{sku.id}
</foreach>
</update>
<select id="listByClientId" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
SELECT s.id,
s.erp_code,
p.en_name as productEn,
p.zh_name as product
FROM sku s
JOIN client_sku ON s.id = client_sku.sku_id
JOIN product p ON s.product_id = p.id
WHERE client_sku.client_id = #{clientId};
</select>
</mapper>

View File

@ -2,11 +2,13 @@ package org.jeecg.modules.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.Order;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.OrderListRequestBody;
import org.jeecg.modules.business.vo.PlatformOrderOperation;
import org.jeecg.modules.business.vo.Responses;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutorService;
/**
* Services related to operations on {@code Order} entity
@ -32,4 +34,10 @@ public interface IPlatformOrderMabangService extends IService<Order> {
Responses suspendOrder(PlatformOrderOperation orderOperation);
Responses cancelOrders(PlatformOrderOperation orderOperation);
List<Order> getOrdersFromMabang(List<OrderListRequestBody> requests, ExecutorService executor);
void clearLogisticChannel(List<Order> orders, ExecutorService executor);
String stripAccents(String input);
}

View File

@ -17,10 +17,7 @@ import org.jeecg.modules.business.vo.clientPlatformOrder.section.OrdersStatistic
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Description:
@ -206,9 +203,13 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
* Find all order that can be invoiced (shipping and purchase).
* @param shopIds
* @param erpStatuses
* @param column
* @param order
* @param pageNo
* @param pageSize
* @return
*/
List<PlatformOrder> findUninvoicedOrdersByShopForClient(List<String> shopIds, List<Integer> erpStatuses);
List<PlatformOrder> findUninvoicedOrdersByShopForClient(List<String> shopIds, List<Integer> erpStatuses, String column, String order, Integer pageNo, Integer pageSize);
/**
* Get ids of all order that can be invoiced by small clients (type 2) themselves.
* @param shopIds list of shop id

View File

@ -0,0 +1,5 @@
package org.jeecg.modules.business.service;
public interface ISecurityService {
boolean checkIsEmployee();
}

View File

@ -18,4 +18,8 @@ public interface IShopService extends IService<Shop> {
List<String> listIdByClient(String clientID);
List<String> getShopIdsByClientAndType(List<String> clientIds, String clientType);
String getNameById(String shopId);
String getCodeById(String shopId);
}

View File

@ -95,12 +95,13 @@ public interface ISkuService extends IService<Sku> {
List<SkuQuantity> getSkuQuantitiesFromOrderIds(List<String> orderIds);
List<SkuOrderPage> fetchSkusByClient(String clientId);
List<SkuOrderPage> fetchSkusByClient(String clientId, Integer pageNo, Integer pageSize, String column, String order);
List<SkuOrderPage> fetchSkusByClientWithFilters(String clientId, Integer pageNo, Integer pageSize, String column, String order, List<String> erpCodes, List<String> zhNames, List<String> enNames);
void addSkuQuantity(Map<String, Integer> quantityPurchased);
String getIdFromErpCode(String erpCode);
Sku getByErpCode(String erpCode);
void updateBatchStockByIds(List<Sku> skuToUpdate);
List<SkuOrderPage> getInventoryByInvoiceNumber(String invoiceNumber);
List<Sku> listByClientId(String clientId);
}

View File

@ -4,12 +4,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderRequest;
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderRequestBody;
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderResponse;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.Order;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.OrderItem;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.OrderStatus;
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.*;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.*;
import org.jeecg.modules.business.domain.api.mabang.orderDoOrderAbnormal.OrderSuspendRequest;
import org.jeecg.modules.business.domain.api.mabang.orderDoOrderAbnormal.OrderSuspendRequestBody;
import org.jeecg.modules.business.domain.api.mabang.orderDoOrderAbnormal.OrderSuspendResponse;
@ -23,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.Normalizer;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
@ -267,7 +264,64 @@ public class PlatformOrderMabangServiceImpl extends ServiceImpl<PlatformOrderMab
return responses;
}
private void updateExistedOrders(List<Order> orders) {
/**
*
* @param requests List<OrderListRequestBody>
* @param executor ExecutorService
* @return orders retrieved from mabang
*/
@Override
public List<Order> getOrdersFromMabang(List<OrderListRequestBody> requests, ExecutorService executor) {
List<Order> mabangOrders = new ArrayList<>();
List<CompletableFuture<Boolean>> futures = requests.stream()
.map(request -> CompletableFuture.supplyAsync(() -> {
boolean success = false;
try {
OrderListRawStream rawStream = new OrderListRawStream(request);
OrderListStream stream = new OrderListStream(rawStream);
List<Order> orders = stream.all();
mabangOrders.addAll(orders);
success = !orders.isEmpty();
} catch (RuntimeException e) {
log.error("Error communicating with MabangAPI", e);
}
return success;
}, executor))
.collect(Collectors.toList());
List<Boolean> results = futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
long nbSuccesses = results.stream().filter(b -> b).count();
log.info("{}/{} requests have succeeded.", nbSuccesses, requests.size());
log.info("{}/{} mabang orders have been retrieved.", mabangOrders.size(), requests.size());
return mabangOrders;
}
/**
* Sends a request to clear orders Logistic Channel to Mabang
* (usually it is called upon modifying an order)
* @param orders List<Order>
* @param executor Executor Service
*/
@Override
public void clearLogisticChannel(List<Order> orders, ExecutorService executor) {
// First we delete the logistic channel names, otherwise we can't delete virtual skus
List<CompletableFuture<Boolean>> clearLogisticFutures = orders.stream()
.map(order -> CompletableFuture.supplyAsync(() -> {
ClearLogisticRequestBody body = new ClearLogisticRequestBody(order.getPlatformOrderId());
ClearLogisticRequest request = new ClearLogisticRequest(body);
ClearLogisticResponse response = request.send();
return response.success();
}, executor))
.collect(Collectors.toList());
List<Boolean> logisticResults = clearLogisticFutures.stream().map(CompletableFuture::join).collect(Collectors.toList());
long logisticClearSuccessCount = logisticResults.stream().filter(b -> b).count();
log.info("{}/{} logistic channel names cleared successfully.", logisticClearSuccessCount, orders.size());
}
@Override
public String stripAccents(String input) {
input = Normalizer.normalize(input, Normalizer.Form.NFD);
input = input.replaceAll("[^\\p{ASCII}]", "");
return input;
}
}

View File

@ -430,8 +430,9 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
}
@Override
public List<PlatformOrder> findUninvoicedOrdersByShopForClient(List<String> shopIds, List<Integer> erpStatuses) {
return platformOrderMap.findUninvoicedOrdersByShopForClient(shopIds, erpStatuses);
public List<PlatformOrder> findUninvoicedOrdersByShopForClient(List<String> shopIds, List<Integer> erpStatuses, String column, String order, Integer pageNo, Integer pageSize) {
int offset = (pageNo - 1) * pageSize;
return platformOrderMap.findUninvoicedOrdersByShopForClient(shopIds, erpStatuses, column, order, offset, pageSize);
}
@Override

View File

@ -0,0 +1,24 @@
package org.jeecg.modules.business.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.business.service.ISecurityService;
import org.jeecg.modules.system.service.ISysDepartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class SecurityServiceImp implements ISecurityService {
@Autowired private ISysDepartService sysDepartService;
@Autowired private Environment env;
@Override
public boolean checkIsEmployee() {
String companyOrgCode = sysDepartService.queryCodeByDepartName(env.getProperty("company.orgName"));
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
return sysUser.getOrgCode().equals(companyOrgCode);
}
}

View File

@ -38,4 +38,14 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IS
public List<String> getShopIdsByClientAndType(List<String> clientIds, String clientType) {
return shopMapper.getShopIdsByClientAndType(clientIds, clientType);
}
@Override
public String getNameById(String shopId) {
return shopMapper.getNameById(shopId);
}
@Override
public String getCodeById(String shopId) {
return shopMapper.getCodeById(shopId);
}
}

View File

@ -417,8 +417,37 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
}
@Override
public List<SkuOrderPage> fetchSkusByClient(String clientId) {
return skuMapper.fetchSkusByClient(clientId);
public List<SkuOrderPage> fetchSkusByClient(String clientId, Integer pageNo, Integer pageSize, String column, String order) {
int offset = (pageNo - 1) * pageSize;
return skuMapper.fetchSkusByClient(clientId, offset, pageSize, column, order);
}
@Override
public List<SkuOrderPage> fetchSkusByClientWithFilters(String clientId, Integer pageNo, Integer pageSize, String column, String order, List<String> erpCodes, List<String> zhNames, List<String> enNames) {
int offset = (pageNo - 1) * pageSize;
StringBuilder erpCodesRegex= new StringBuilder(), zhNamesRegex = new StringBuilder(), enNamesRegex = new StringBuilder();
if(erpCodes != null){
erpCodesRegex.append("^");
for(String name : erpCodes){
erpCodesRegex.append("(?=.*").append(name).append(")");
}
erpCodesRegex.append(".*");
}
if(enNames != null){
enNamesRegex.append("^");
for(String name : enNames){
enNamesRegex.append("(?=.*").append(name).append(")");
}
enNamesRegex.append(".*");
}
if(zhNames != null){
zhNamesRegex.append("^");
for(String name : zhNames){
zhNamesRegex.append("(?=.*").append(name).append(")");
}
zhNamesRegex.append(".*$");
}
return skuMapper.fetchSkusByClientWithFilters(clientId, offset, pageSize, column, order, erpCodesRegex.toString(), zhNamesRegex.toString(), enNamesRegex.toString());
}
@Override
@ -446,4 +475,9 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
return skuMapper.getInventoryByInvoiceNumber(invoiceNumber);
}
@Override
public List<Sku> listByClientId(String clientId) {
return skuMapper.listByClientId(clientId);
}
}

View File

@ -9,32 +9,47 @@ import java.util.List;
@Data
public class Estimation {
private String code;
private Integer ordersToProcess;
private Integer processedOrders;
private BigDecimal shippingFeesEstimation;
private BigDecimal purchaseEstimation;
private BigDecimal totalEstimation;
private String currency;
private List<String> errorMessages;
private String shop = "";
private List<String> shopIds;
private String startDate;
private String endDate;
private boolean isCompleteInvoiceReady;
public Estimation(@JsonProperty("shippingFeesEstimation") BigDecimal shippingFeesEstimation,
private List<String> orderIds;
public Estimation(@JsonProperty("code") String code,
@JsonProperty("ordersToProcess") Integer ordersToProcess,
@JsonProperty("processedOrders") Integer processedOrders,
@JsonProperty("shippingFeesEstimation") BigDecimal shippingFeesEstimation,
@JsonProperty("purchaseEstimation") BigDecimal purchaseEstimation,
@JsonProperty("currency") String currency,
@JsonProperty("errorMessages") List<String> errorMessages,
@JsonProperty("orderIds") List<String> shopIds,
@JsonProperty("shop") String shop,
@JsonProperty("shopIds") List<String> shopIds,
@JsonProperty("startDate") String startDate,
@JsonProperty("endDate") String endDate,
@JsonProperty("isCompleteInvoiceReady") boolean isCompleteInvoiceReady) {
@JsonProperty("isCompleteInvoiceReady") boolean isCompleteInvoiceReady,
@JsonProperty("orderIds") List<String> orderIds
) {
this.code = code;
this.ordersToProcess = ordersToProcess;
this.processedOrders = processedOrders;
this.currency = currency;
this.purchaseEstimation = purchaseEstimation;
this.shippingFeesEstimation = shippingFeesEstimation;
this.errorMessages = errorMessages;
this.shop = shop;
this.shopIds = shopIds;
this.startDate = startDate;
this.endDate = endDate;
this.isCompleteInvoiceReady = isCompleteInvoiceReady;
this.orderIds = orderIds;
totalEstimation = shippingFeesEstimation.add(purchaseEstimation).setScale(2, RoundingMode.CEILING);
}
}

View File

@ -13,10 +13,19 @@ public class PlatformOrderOperation {
private String action;
@JSONField(name = "reason")
private String reason;
@JSONField(name = "recipient")
private String recipient;
@JSONField(name = "phone")
private String phone;
@JSONField(name = "street1")
private String street1;
@JSONField(name = "street2")
private String street2;
public enum Action {
CANCEL("cancel"),
SUSPEND("suspend");
SUSPEND("suspend"),
EDIT("edit");
private final String action;

View File

@ -37,6 +37,22 @@
</tr>
</#if>
</#if>
<#if editSuccessCount??>
<tr>
<td style="padding:0 0 35px 0;">Demandes de modification d'informations de commande : <b>${editSuccessCount}</b> réussie(s)</td>
</tr>
<#if editFailures?size gt 0 >
<tr>
<td style="padding:0 0 35px 0;">Demandes de modification de commande échouées :<br/>
<ul>
<#list editFailures as failure>
<li>${failure}</li>
</#list>
</ul>
</td>
</tr>
</#if>
</#if>
<tr>
<td style="padding:0 0 35px 0;">Pour toute information complémentaire nous vous invitons à vous rapprocher de votre conseiller.</td>
</tr>