Merge branch 'dev' of github.com:LQYBill/wia_app into feat/mabangOrderRemark

pull/8523/head
Gauthier LO 2025-05-05 11:22:44 +02:00
commit 12fa98eabf
19 changed files with 511 additions and 93 deletions

View File

@ -245,8 +245,8 @@ public class PlatformOrderController {
@ApiOperation(value = "Order content query", notes = "Query order contents by order's identifier")
@GetMapping(value = "/queryPlatformOrderContentByMainId")
public Result<?> queryPlatformOrderContentListByMainId(@RequestParam(name = "id") String id) {
List<PlatformOrderContent> platformOrderContentList = platformOrderService.selectByMainId(id);
IPage<PlatformOrderContent> page = new Page<>();
List<PlatformOrderContentFront> platformOrderContentList = platformOrderService.selectByMainIdAndSkuSync(id);
IPage<PlatformOrderContentFront> page = new Page<>();
page.setRecords(platformOrderContentList);
page.setTotal(platformOrderContentList.size());
return Result.OK(page);

View File

@ -4,6 +4,7 @@ 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 com.google.common.collect.Lists;
import freemarker.template.Template;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -14,7 +15,12 @@ import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuData;
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuListRawStream;
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuListRequestBody;
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuUpdateListStream;
import org.jeecg.modules.business.entity.*;
import org.jeecg.modules.business.model.SkuDocument;
import org.jeecg.modules.business.mongoService.SkuMongoService;
import org.jeecg.modules.business.service.*;
import org.jeecg.modules.business.vo.*;
@ -63,6 +69,8 @@ public class SkuController {
@Autowired
private ISkuService skuService;
@Autowired
private ISkuWeightService skuWeightService;
@Autowired
private ISkuPriceService skuPriceService;
@Autowired
private IShippingDiscountService shippingDiscountService;
@ -367,11 +375,6 @@ 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("/listWithFilters")
public Result<?> listWithFilters(@RequestParam(name = "clientId", required = false) String clientId,
@ -614,4 +617,76 @@ public class SkuController {
@RequestParam(name= "date") String date) {
return Result.OK(skuService.latestSkuCounter(userCode, clientCode, date));
}
@GetMapping(value = "/compare")
public Result<?> compareClientSkuWithMabang(@RequestParam(name="clientId") String clientId,
@RequestParam(name="erpStatuses[]") List<String> erpStatuses) {
Map<String, Sku> clientSkus = skuService.listInUninvoicedOrders(clientId, erpStatuses);
List<String> skuIds = new ArrayList<>(clientSkus.keySet());
List<SkuDocument> clientSkuDocs = new ArrayList<>();
for(String skuId: skuIds) {
List<SkuDocument> skus = skuMongoService.findBySkuId(skuId);
if(skus.isEmpty()) {
skuMongoService.migrateOneSku(clientSkus.get(skuId));
skus = skuMongoService.findBySkuId(skuId);
}
SkuDocument sku = skus.get(0);
clientSkuDocs.add(sku);
}
List<List<String>> erpCodePartition = Lists.partition(clientSkuDocs, 50)
.stream()
.map(skus -> skus.stream().map(SkuDocument::getErpCode).collect(Collectors.toList()))
.collect(Collectors.toList());
List<SkuData> skusFromMabang = new ArrayList<>();
for(List<String> partition : erpCodePartition) {
SkuListRequestBody body = new SkuListRequestBody();
body.setStockSkuList(String.join(",", partition));
SkuListRawStream rawStream = new SkuListRawStream(body);
SkuUpdateListStream stream = new SkuUpdateListStream(rawStream);
skusFromMabang.addAll(stream.all());
}
List<String> desyncedSkus = new ArrayList<>();
List<String> syncedSkus = new ArrayList<>();
for(SkuDocument sku : clientSkuDocs) {
SkuData skuData = skusFromMabang.stream().filter(s -> s.getErpCode().equals(sku.getErpCode()))
.findFirst().orElse(null);
if(skuData != null) {
boolean isDesynced = false;
BigDecimal mabangPrice = skuData.getSalePrice().setScale(2, RoundingMode.HALF_UP); // because price from mabang has 4 decimal places, so Objects.equals will always return false
if(skuData.getWeight() == null && sku.getLatestSkuWeight() != null) {
log.info("sku {} doesn't have a weight on Mabang but has one in Mongo", skuData.getErpCode());
isDesynced = true;
}
if (sku.getLatestSkuWeight() != null && !Objects.equals(skuData.getWeight(), sku.getLatestSkuWeight().getWeight())) {
log.info("sku {} has a different weight on Mabang and in Mongo : mabang :{}; mongo :{}", skuData.getErpCode() ,skuData.getWeight(), sku.getLatestSkuWeight().getWeight());
isDesynced = true;
}
if(skuData.getSalePrice() == null && sku.getLatestSkuPrice() != null) {
log.info("sku {} doesn't have a price on Mabang but has one in mongo", skuData.getErpCode());
isDesynced = true;
}
if(sku.getLatestSkuPrice() != null && !Objects.equals(mabangPrice, sku.getLatestSkuPrice().getPrice())) {
log.info("sku {} has a different price on Mabang and in Mongo : mabang :{}; mongo :{}", skuData.getErpCode() ,skuData.getSalePrice(), sku.getLatestSkuPrice().getPrice());
isDesynced = true;
}
if(isDesynced)
desyncedSkus.add(skuData.getErpCode());
else
syncedSkus.add(skuData.getErpCode());
} else {
desyncedSkus.add(sku.getErpCode());
}
}
if(!desyncedSkus.isEmpty()) {
log.info("Desynced skus : {}", desyncedSkus);
skuService.setIsSynced(desyncedSkus, false);
}
if(!syncedSkus.isEmpty()) {
log.info("Synced skus : {}", syncedSkus);
skuService.setIsSynced(syncedSkus, true);
}
return Result.OK();
}
}

View File

@ -56,6 +56,7 @@ import static org.jeecg.common.util.SqlInjectionUtil.specialFilterContentForDict
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.*;
/**
* Controller for request related to shipping invoice
@ -157,67 +158,40 @@ public class InvoiceController {
@GetMapping(value = "/orders")
public Result<?> getOrdersByClientAndShops(PlatformOrder platformOrder,
@RequestParam("clientId") String clientId,
@RequestParam(name = "shopIds[]", required = false) List<String> shopIDs,
@RequestParam(name = "start", required = false) String start,
@RequestParam(name = "end", required = false) String end,
@RequestParam(name = "shopIds[]") List<String> shopIDs,
@RequestParam(name = "start") String start,
@RequestParam(name = "end") String end,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(name = "type") String type,
@RequestParam(name = "warehouses[]") List<String> warehouses,
HttpServletRequest req) {
String warehouseString = String.join(",", warehouses);
QueryWrapper<PlatformOrder> queryWrapper = QueryGenerator.initQueryWrapper(platformOrder, req.getParameterMap());
LambdaQueryWrapper<PlatformOrder> lambdaQueryWrapper = queryWrapper.lambda();
switch (type) {
case "shipping":
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, OrderStatus.Shipped.getCode());
break;
case "pre-shipping":
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, Arrays.asList(OrderStatus.Pending.getCode(), OrderStatus.Preparing.getCode()));
break;
case "all":
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, Arrays.asList(OrderStatus.Pending.getCode(), OrderStatus.Preparing.getCode(), OrderStatus.Shipped.getCode()));
break;
default:
return Result.error("Error 404 : page not found.");
@RequestParam(name = "column", defaultValue = "shop_id") String column,
@RequestParam(name = "order", defaultValue = "ASC") String order
) {
log.info("Request for {} orders from client : {} between {} and {} for shops : {}", type, clientId, start, end, 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");
}
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
Page<PlatformOrder> page = new Page<>(pageNo, pageSize);
IPage<PlatformOrder> pageList;
log.info("Request for " + type + " orders from client : " + clientId);
if (shopIDs == null || shopIDs.isEmpty()) { // obsolete, used in old pages only
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT po.id FROM platform_order po\n" +
" JOIN shop s ON po.shop_id = s.id\n" +
" JOIN client c ON s.owner_id = c.id WHERE c.id = '" + clientId + "'");
pageList = platformOrderMapper.selectPage(page, lambdaQueryWrapper);
} else {
log.info("Specified shop IDs : " + shopIDs);
lambdaQueryWrapper.in(PlatformOrder::getShopId, shopIDs);
if(start != null || end != null){
log.info("Specified period between " + start + " and " + end);
if (type.equals("shipping"))
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT po.id FROM platform_order po\n" +
"LEFT JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name\n" +
"WHERE po.shipping_time between '" + start + "' AND '" + end + "'\n" +
"AND (lc.warehouse_in_china IN (" + warehouseString + ") OR po.logistic_channel_name = '' OR po.logistic_channel_name IS NULL)");
else
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT po.id FROM platform_order po\n" +
"LEFT JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name\n" +
"WHERE po.order_time between '" + start + "' AND '" + end + "'\n" +
"AND (lc.warehouse_in_china IN (" + warehouseString + ") OR po.logistic_channel_name = '' OR po.logistic_channel_name IS NULL)");
}
else {// obsolete
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT po.id FROM platform_order po\n" +
"JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name\n" +
"WHERE (lc.warehouse_in_china IN (" + warehouseString + ") OR po.logistic_channel_name = '' OR po.logistic_channel_name IS NULL)");
}
pageList = platformOrderMapper.selectPage(page, lambdaQueryWrapper);
return Result.OK(pageList);
try {
specialFilterContentForDictSql(parsedColumn);
} catch (RuntimeException e) {
return Result.error("Error 400 Bad Request");
}
if (pageList.getSize() > 0) {
return Result.OK(pageList);
List<PlatformOrderFront> orders = platformOrderService.listByClientAndShops(clientId, shopIDs, start, end, type, pageNo, pageSize, warehouses, order, parsedColumn);
int total = platformOrderService.countListByClientAndShops(clientId, shopIDs, start, end, type, warehouses);
if (!orders.isEmpty()) {
IPage<PlatformOrderFront> page = new Page<>();
page.setRecords(orders);
page.setCurrent(pageNo);
page.setSize(pageSize);
page.setTotal(total);
return Result.OK(page);
}
return Result.error("No orders for selected client/shops");
return Result.error(404, "No orders for selected client/shops");
}
@PostMapping(value = "/period")
public Result<?> getValidPeriod(@RequestBody List<String> shopIDs) {
@ -540,7 +514,7 @@ public class InvoiceController {
log.info("User : {} is requesting uninvoiced orders for shops : [{}]",
((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername(),
shopIds);
List<Integer> productStatuses = productAvailable == null || productAvailable.isEmpty() ? Arrays.asList(Integer.valueOf(PlatformOrderFront.productStatus.Unavailable.code), Integer.valueOf(PlatformOrderFront.productStatus.Available.code), Integer.valueOf(PlatformOrderFront.productStatus.Ordered.code)) : productAvailable;
List<Integer> productStatuses = productAvailable == null || productAvailable.isEmpty() ? Arrays.asList(Integer.valueOf(productStatus.Unavailable.code), Integer.valueOf(productStatus.Available.code), Integer.valueOf(productStatus.Ordered.code)) : productAvailable;
String parsedColumn = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, column.replace("_dictText",""));
String parsedOrder = order.toUpperCase();
if(!parsedOrder.equals("ASC") && !parsedOrder.equals("DESC")) {

View File

@ -20,6 +20,9 @@ public enum OrderStatus {
public String getCode() {
return String.valueOf(code);
}
public Integer getCodeInt() {
return code;
}
public static OrderStatus fromCode(Integer code) {
for (OrderStatus orderStatus : OrderStatus.values()) {

View File

@ -119,6 +119,28 @@ public class Invoice implements Serializable {
}
}
@Getter
public enum InvoicingMethod {
PRESHIPPING ("pre-shipping"),
POSTSHIPPING("post-shipping"),
ALL("all");
private final String method;
public static InvoicingMethod fromString(String method) {
for(InvoicingMethod invoicingMethod : InvoicingMethod.values()) {
if(invoicingMethod.method.equalsIgnoreCase(method)) {
return invoicingMethod;
}
}
throw new IllegalArgumentException("Incorrect invoicing method : " + method);
}
InvoicingMethod(String method) {
this.method = method;
}
}
@Getter
public enum Status {
Cancelled (0),

View File

@ -41,7 +41,7 @@ public class PlatformOrder implements Serializable {
/**
*
*/
@TableId(type = IdType.ASSIGN_ID)
@TableId(type = IdType.ASSIGN_UUID)
@ApiModelProperty(value = "主键")
private String id;
/**

View File

@ -126,4 +126,10 @@ public class Sku implements Serializable {
*/
@JSONField(name="isGift")
private Integer isGift;
/**
* 0;1
*/
@Excel(name = "是否一致", width = 15, dicCode = "is_synced")
@JSONField(name="isSynced")
private Integer isSynced;
}

View File

@ -6,6 +6,7 @@ import org.jeecg.modules.business.entity.ClientPlatformOrderContent;
import org.jeecg.modules.business.entity.PlatformOrderContent;
import org.jeecg.modules.business.entity.SkuPrice;
import org.jeecg.modules.business.entity.ShoumanOrderContent;
import org.jeecg.modules.business.vo.PlatformOrderContentFront;
import org.jeecg.modules.business.vo.SkuDetail;
import org.jeecg.modules.business.vo.SkuQuantity;
import org.jeecg.modules.business.vo.SkuWeightDiscountServiceFees;
@ -27,6 +28,8 @@ public interface PlatformOrderContentMapper extends BaseMapper<PlatformOrderCont
List<PlatformOrderContent> selectByMainId(@Param("mainId") String mainId);
List<PlatformOrderContentFront> selectByMainIdAndSkuSync(@Param("mainId") String mainId);
List<ClientPlatformOrderContent> selectClientVersionByMainId(@Param("mainId") String mainId);
/**

View File

@ -245,4 +245,14 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
Integer countPotentialShoumanOrders();
List<String> getPlatformOrderIdsByInvoiceNumbers(@Param("invoiceNumbers") List<String> invoiceNumbers);
int countListByClientAndShops(@Param("clientId") String clientId,@Param("shopIds") List<String> shopIds,
@Param("erpStatuses") List<Integer> erpStatuses,
@Param("warehouses") List<String> warehouses,
@Param("start") String startDate, @Param("end") String endDate);
List<PlatformOrderFront> listByClientAndShops(@Param("clientId") String clientId,@Param("shopIds") List<String> shopIds,
@Param("erpStatuses") List<Integer> erpStatuses,
@Param("warehouses") List<String> warehouses,
@Param("start") String startDate, @Param("end") String endDate,
@Param("order") String order, @Param("column") String column,
@Param("offset") Integer offset, @Param("size") Integer pageSize);
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.business.entity.Sku;
import org.jeecg.modules.business.vo.SkuOrderPage;
@ -74,7 +75,8 @@ public interface SkuMapper extends BaseMapper<Sku> {
List<SkuOrderPage> getInventory(@Param("erpCodes") List<String> erpCodes, @Param("invoiceNumber") String invoiceNumber);
List<Sku> listByClientId(@Param("clientId") String clientId);
@MapKey("id")
Map<String, Sku> listInUninvoicedOrders(@Param("clientId") String clientId, @Param("erpStatuses") List<String> erpStatuses);
List<SkuOrderPage> searchExistingSkuByKeywords(@Param("keywords") List<String> keywords);
List<Sku> listImgUrls();
@ -86,4 +88,6 @@ public interface SkuMapper extends BaseMapper<Sku> {
int countUnpairedSkus(@Param("shopId") String shopId);
List<String> latestSkuCounter(@Param("userCode") String userCode, @Param("clientCode") String clientCode, @Param("date") String date);
void setIsSynced(@Param("erpCodes")List<String> erpCodes, @Param("isSynced") boolean isSynced);
}

View File

@ -30,7 +30,29 @@
resultType="org.jeecg.modules.business.entity.PlatformOrderContent">
SELECT *
FROM platform_order_content
WHERE platform_order_id = #{mainId} </select>
WHERE platform_order_id = #{mainId}
</select>
<select id="selectByMainIdAndSkuSync" parameterType="java.lang.String"
resultType="org.jeecg.modules.business.vo.PlatformOrderContentFront">
SELECT poc.id,
poc.platform_order_id,
poc.sku_id,
poc.quantity,
poc.purchase_fee,
poc.shipping_fee,
poc.service_fee,
poc.picking_fee,
poc.insurance_fee,
poc.vat,
poc.status,
poc.erp_status,
poc.product_available,
s.is_synced
FROM platform_order_content poc
JOIN sku s ON poc.sku_id = s.id
WHERE platform_order_id = #{mainId};
</select>
<select id="selectClientVersionByMainId" parameterType="java.lang.String"
resultType="org.jeecg.modules.business.entity.ClientPlatformOrderContent">

View File

@ -1280,4 +1280,91 @@
#{invoiceNumber}
</foreach>
</select>
<select id="countListByClientAndShops" resultType="java.lang.Integer">
SELECT count(po.id)
FROM platform_order po
JOIN platform_order_content poc ON po.id = poc.platform_order_id
JOIN sku s ON poc.sku_id = s.id
JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name
WHERE po.erp_status IN
<foreach collection="erpStatuses" separator="," open="(" close=")" index="index" item="erpStatus">
#{erpStatus}
</foreach>
AND po.shop_id IN
<foreach collection="shopIds" separator="," open="(" close=")" index="index" item="shopId">
#{shopId}
</foreach>
AND (
lc.warehouse_in_china IN
<foreach collection="warehouses" separator="," open="(" close=")" index="index" item="warehouse">
#{warehouse}
</foreach>
OR po.logistic_channel_name = ''
OR po.logistic_channel_name IS NULL
)
<if test="erpStatuses.size == 1">
AND po.shipping_time BETWEEN #{start} AND #{end}
</if>
<if test="erpStatuses.size > 1">
AND po.order_time BETWEEN #{start} AND #{end}
</if>
</select>
<select id="listByClientAndShops" resultType="org.jeecg.modules.business.vo.PlatformOrderFront">
WITH orders AS (
SELECT po.id as id,
po.shop_id as shop_id,
po.platform_order_number as platform_order_number,
po.platform_order_id as platform_order_id,
po.logistic_channel_name as logistic_channel_name,
po.invoice_logistic_channel_name as invoice_logistic_channel_name,
po.tracking_number as tracking_number,
po.order_time as order_time,
po.country as country,
po.fret_fee as fret_fee,
po.order_service_fee as order_service_fee,
po.erp_status as erp_status,
po.can_send as can_send,
po.product_available as product_available
FROM platform_order po
JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name
WHERE po.erp_status IN
<foreach collection="erpStatuses" separator="," open="(" close=")" index="index" item="erpStatus">
#{erpStatus}
</foreach>
AND po.shop_id IN
<foreach collection="shopIds" separator="," open="(" close=")" index="index" item="shopId">
#{shopId}
</foreach>
AND (
lc.warehouse_in_china IN
<foreach collection="warehouses" separator="," open="(" close=")" index="index" item="warehouse">
#{warehouse}
</foreach>
OR po.logistic_channel_name = ''
OR po.logistic_channel_name IS NULL
)
<if test="erpStatuses.size == 1">
AND po.shipping_time BETWEEN #{start} AND #{end}
</if>
<if test="erpStatuses.size > 1">
AND po.order_time BETWEEN #{start} AND #{end}
</if>
AND po.shipping_invoice_number IS NULL
ORDER BY ${column} ${order}
LIMIT #{offset}, #{size}
)
SELECT orders.*,
CASE
WHEN EXISTS (
SELECT 1
FROM platform_order_content poc
JOIN sku s ON poc.sku_id = s.id
WHERE poc.platform_order_id = orders.id
AND s.is_synced = 0
AND poc.erp_status &lt;&gt; 5
) THEN 1
ELSE 0
END as has_desynced_sku
FROM orders
</select>
</mapper>

View File

@ -723,14 +723,22 @@
#{sku.id}
</foreach>
</update>
<select id="listByClientId" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
SELECT s.id,
s.erp_code,
s.en_name,
s.zh_name
<select id="listInUninvoicedOrders" resultType="org.jeecg.modules.business.entity.Sku">
SELECT DISTINCT s.*
FROM sku s
JOIN client_sku ON s.id = client_sku.sku_id
WHERE client_sku.client_id = #{clientId};
JOIN client_sku ON s.id = client_sku.sku_id
JOIN platform_order_content poc ON s.id = poc.sku_id
JOIN platform_order po ON poc.platform_order_id = po.id
WHERE client_sku.client_id = #{clientId}
AND po.shipping_invoice_number IS NULL
AND poc.erp_status &lt;&gt; 5
AND po.erp_status IN
<foreach collection="erpStatuses" item="erpStatus" index="index" separator="," open="(" close=")">
#{erpStatus}
</foreach>
AND po.order_time &gt;= '2024-01-01 00:00:00'
AND s.status = 3
;
</select>
<select id="searchExistingSkuByKeywords" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
SELECT
@ -821,4 +829,12 @@
FROM sku s
WHERE erp_code LIKE CONCAT(#{date}, #{userCode}, '%%%-', #{clientCode});
</select>
<update id="setIsSynced">
UPDATE sku
SET is_synced = IF(#{isSynced} = true, 1, 0)
WHERE erp_code IN
<foreach collection="erpCodes" item="erpCode" index="index" separator="," open="(" close=")">
#{erpCode}
</foreach>;
</update>
</mapper>

View File

@ -59,6 +59,8 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
List<PlatformOrderContent> selectByMainId(String mainId);
List<PlatformOrderContentFront> selectByMainIdAndSkuSync(String mainId);
List<ClientPlatformOrderContent> selectClientVersionByMainId(String mainId);
PurchaseConfirmation confirmPurchaseByPlatformOrder(List<String> platformOrderIdList) throws UserException;
@ -287,4 +289,8 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
void pagePotentialShoumanOrders(IPage<PlatformOrderPage> page, String column, String order);
List<String> getPlatformOrderIdsByInvoiceNumbers(List<String> invoiceNumbers);
List<PlatformOrderFront> listByClientAndShops(String clientId, List<String> shopIds, String startDate, String endDate, String invoicingMethod, Integer pageNo, Integer pageSize, List<String> warehouses, String order, String column);
int countListByClientAndShops(String clientId, List<String> shopIDs, String start, String end, String invoicingMethod, List<String> warehouses);
}

View File

@ -113,7 +113,7 @@ public interface ISkuService extends IService<Sku> {
List<SkuOrderPage> getInventoryByInvoiceNumber(String invoiceNumber);
List<SkuOrderPage> getInventory(List<String> erpCodes, String invoiceNumber);
List<Sku> listByClientId(String clientId);
Map<String, Sku> listInUninvoicedOrders(String clientId, List<String> erpStatuses);
List<SkuOrderPage> searchExistingSkuByKeywords(List<String> keywords);
@ -130,4 +130,6 @@ public interface ISkuService extends IService<Sku> {
int countUnpairedSkus(String shopId);
int latestSkuCounter(String userCode, String clientCode, String date);
void setIsSynced(List<String> erpCodes, boolean isSynced);
}

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.controller.UserException;
import org.jeecg.modules.business.domain.api.mabang.getorderlist.OrderStatus;
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberData;
import org.jeecg.modules.business.entity.*;
import org.jeecg.modules.business.mapper.ExchangeRatesMapper;
@ -23,6 +24,7 @@ import org.jeecg.modules.business.vo.clientPlatformOrder.section.OrdersStatistic
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.jeecg.modules.business.entity.Invoice.InvoicingMethod;
import java.io.Serializable;
import java.math.BigDecimal;
@ -35,6 +37,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.*;
import static org.jeecg.modules.business.entity.Invoice.InvoicingMethod.*;
/**
* @Description:
@ -46,22 +49,16 @@ import static java.util.stream.Collectors.*;
@Slf4j
public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, PlatformOrder> implements IPlatformOrderService {
private final PlatformOrderMapper platformOrderMap;
private final PlatformOrderContentMapper platformOrderContentMap;
private final IShippingFeesWaiverProductService shippingFeesWaiverProductService;
private final IClientService clientService;
private final ExchangeRatesMapper exchangeRatesMapper;
@Autowired
public PlatformOrderServiceImpl(PlatformOrderMapper platformOrderMap, PlatformOrderContentMapper platformOrderContentMap,
IShippingFeesWaiverProductService shippingFeesWaiverProductService, IClientService clientService,
ExchangeRatesMapper exchangeRatesMapper) {
this.platformOrderMap = platformOrderMap;
this.platformOrderContentMap = platformOrderContentMap;
this.shippingFeesWaiverProductService = shippingFeesWaiverProductService;
this.clientService = clientService;
this.exchangeRatesMapper = exchangeRatesMapper;
}
private PlatformOrderMapper platformOrderMap;
@Autowired
private PlatformOrderContentMapper platformOrderContentMap;
@Autowired
private IShippingFeesWaiverProductService shippingFeesWaiverProductService;
@Autowired
private IClientService clientService;
@Autowired
private ExchangeRatesMapper exchangeRatesMapper;
@Override
@Transactional
@ -188,12 +185,16 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
return OrdersStatisticData.makeData(data, null);
}
@Override
public List<PlatformOrderContent> selectByMainId(String mainId) {
return platformOrderContentMap.selectByMainId(mainId);
}
@Override
public List<PlatformOrderContentFront> selectByMainIdAndSkuSync(String mainId) {
return platformOrderContentMap.selectByMainIdAndSkuSync(mainId);
}
@Override
public List<ClientPlatformOrderContent> selectClientVersionByMainId(String mainId) {
return platformOrderContentMap.selectClientVersionByMainId(mainId);
@ -205,7 +206,6 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
return confirmPurchaseBySkuQuantity(skuIDQuantityMap);
}
@Override
public PurchaseConfirmation confirmPurchaseBySkuQuantity(List<SkuQuantity> skuIDQuantityMap) throws UserException {
Client client = clientService.getCurrentClient();
@ -560,4 +560,44 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
return platformOrderMap.getPlatformOrderIdsByInvoiceNumbers(invoiceNumbers);
}
@Override
public List<PlatformOrderFront> listByClientAndShops(String clientId, List<String> shopIds, String startDate, String endDate, String invoicingMethod, Integer pageNo, Integer pageSize, List<String> warehouses, String order, String column) {
List<Integer> erpStatuses;
InvoicingMethod method = InvoicingMethod.fromString(invoicingMethod);
switch (method) {
case PRESHIPPING :
erpStatuses = Arrays.asList(OrderStatus.Pending.getCodeInt(), OrderStatus.Preparing.getCodeInt());
break;
case POSTSHIPPING:
erpStatuses = Collections.singletonList(OrderStatus.Shipped.getCodeInt());
break;
case ALL :
erpStatuses = Arrays.asList(OrderStatus.Pending.getCodeInt(), OrderStatus.Preparing.getCodeInt(), OrderStatus.Shipped.getCodeInt());
break;
default:
throw new IllegalArgumentException("The specified invoicing method is not supported : " + invoicingMethod);
}
int offset = (pageNo - 1) * pageSize;
return platformOrderMap.listByClientAndShops(clientId, shopIds, erpStatuses, warehouses, startDate, endDate, order, column, offset, pageSize);
}
@Override
public int countListByClientAndShops(String clientId, List<String> shopIDs, String start, String end, String invoicingMethod, List<String> warehouses) {
List<Integer> erpStatuses;
InvoicingMethod method = InvoicingMethod.fromString(invoicingMethod);
switch (method) {
case PRESHIPPING :
erpStatuses = Arrays.asList(OrderStatus.Pending.getCodeInt(), OrderStatus.Preparing.getCodeInt());
break;
case POSTSHIPPING:
erpStatuses = Collections.singletonList(OrderStatus.Shipped.getCodeInt());
break;
case ALL :
erpStatuses = Arrays.asList(OrderStatus.Pending.getCodeInt(), OrderStatus.Preparing.getCodeInt(), OrderStatus.Shipped.getCodeInt());
break;
default:
throw new IllegalArgumentException("The specified invoicing method is not supported : " + invoicingMethod);
}
return platformOrderMap.countListByClientAndShops(clientId, shopIDs, erpStatuses, warehouses, start, end);
}
}

View File

@ -598,8 +598,8 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
}
@Override
public List<Sku> listByClientId(String clientId) {
return skuMapper.listByClientId(clientId);
public Map<String, Sku> listInUninvoicedOrders(String clientId, List<String> erpStatuses) {
return skuMapper.listInUninvoicedOrders(clientId, erpStatuses);
}
@Override
@ -636,4 +636,9 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
}).collect(Collectors.toList());
return counters.stream().max(Integer::compareTo).orElse(0) + 1;
}
@Override
public void setIsSynced(List<String> erpCodes, boolean isSynced) {
skuMapper.setIsSynced(erpCodes, isSynced);
}
}

View File

@ -0,0 +1,100 @@
package org.jeecg.modules.business.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
@Data
@ApiModel(value = "platform_order_content对象", description = "平台订单内容")
public class PlatformOrderContentFront implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(type = IdType.ASSIGN_UUID)
@ApiModelProperty(value = "主键")
private String id;
/**
* ID
*/
@Excel(name = "平台订单ID", width = 15, dictTable = "platform_order", dicText = "platform_order_id", dicCode = "id")
@Dict(dictTable = "platform_order", dicText = "platform_order_id", dicCode = "id")
@ApiModelProperty(value = "平台订单ID")
private String platformOrderId;
/**
* SKU ID
*/
@Excel(name = "SKU ID", width = 15, dictTable = "sku", dicText = "erp_code", dicCode = "id")
@Dict(dictTable = "sku", dicText = "erp_code", dicCode = "id")
@ApiModelProperty(value = "SKU ID")
private String skuId;
/**
* SKU
*/
@Excel(name = "SKU数量", width = 15)
@ApiModelProperty(value = "SKU数量")
private Integer quantity;
/**
*
*/
@Excel(name = "商品采购总费用", width = 15)
@ApiModelProperty(value = "商品采购总费用")
private java.math.BigDecimal purchaseFee;
/**
*
*/
@Excel(name = "物流总费用", width = 15)
@ApiModelProperty(value = "物流总费用")
private java.math.BigDecimal shippingFee;
/**
*
*/
@Excel(name = "服务总费用", width = 15)
@ApiModelProperty(value = "服务总费用")
private java.math.BigDecimal serviceFee;
/**
*
*/
@Excel(name = "海外仓操作费", width = 15)
@ApiModelProperty(value = "海外仓操作费")
private java.math.BigDecimal pickingFee;
/**
*
*/
@Excel(name = "物流保险费", width = 15)
@ApiModelProperty(value = "物流保险费")
private java.math.BigDecimal insuranceFee;
/**
*
*/
@Excel(name = "增值税", width = 15)
@ApiModelProperty(value = "增值税")
private java.math.BigDecimal vat;
/**
* ERP
*/
@Excel(name = "ERP中状态", width = 15)
@ApiModelProperty(value = "ERP中状态")
private String erpStatus;
/**
* 1=0=
*/
@Excel(name = "有货1=有0=没有)", width = 15)
@ApiModelProperty(value = "有货1=有0=没有)")
private String productAvailable;
/**
* 1=0=
* if latest price or weight is not the same in Mongo and Mabang
*/
@Excel(name = "商品是否一致1=一致0=不一致)", width = 15)
@ApiModelProperty(value = "商品是否一致1=一致0=不一致)")
private Integer isSynced;
}

View File

@ -24,7 +24,7 @@ public class PlatformOrderFront {
/**
*
*/
@TableId(type = IdType.ASSIGN_ID)
@TableId(type = IdType.ASSIGN_UUID)
@ApiModelProperty(value = "主键")
private String id;
/**
@ -40,6 +40,31 @@ public class PlatformOrderFront {
@Excel(name = "平台订单交易号", width = 15)
@ApiModelProperty(value = "平台订单交易号")
private String platformOrderNumber;
/**
*
*/
@Excel(name = "平台订单号码", width = 15)
@ApiModelProperty(value = "平台订单号码")
private String platformOrderId;
/**
*
*/
@Excel(name = "物流渠道", width = 15, dictTable = "logistic_channel", dicText = "zh_name", dicCode = "zh_name")
@Dict(dictTable = "logistic_channel", dicText = "zh_name", dicCode = "zh_name")
@ApiModelProperty(value = "物流渠道")
private String logisticChannelName;
/**
*
*/
@Excel(name = "开票物流渠道名称", width = 15)
@ApiModelProperty(value = "开票物流渠道名称")
private String invoiceLogisticChannelName;
/**
*
*/
@Excel(name = "物流跟踪号", width = 15)
@ApiModelProperty(value = "物流跟踪号")
private String trackingNumber;
/**
*
*/
@ -87,6 +112,18 @@ public class PlatformOrderFront {
@Excel(name = "采购发票号", width = 15)
@ApiModelProperty(value = "采购发票号")
private java.lang.String purchaseInvoiceNumber;
/**
* ERP
*/
@Excel(name = "ERP中状态", width = 15)
@ApiModelProperty(value = "ERP中状态")
private String erpStatus;
/**
* 1=2=
*/
@Excel(name = "待审核订单1=正常订单2=异常订单)", width = 15)
@ApiModelProperty(value = "待审核订单1=正常订单2=异常订单)")
private java.lang.String canSend;
/**
* 1=0=
*/
@ -105,6 +142,12 @@ public class PlatformOrderFront {
@Excel(name = "可开采购票0=不可1=可)", width = 15)
@ApiModelProperty(value = "可开采购票0=不可1=可)")
private String purchaseAvailable;
/**
* 1=0=
*/
@Excel(name = "不一致的产品1=有0=没有)", width = 15)
@ApiModelProperty(value = "不一致的产品1=有0=没有)")
private Integer hasDesyncedSku;
private Integer totalCount;