mirror of https://github.com/jeecgboot/jeecg-boot
commit
dbaca2675b
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.jeecg.modules.business.domain.api.mabang.RequestBody;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -18,9 +19,9 @@ public class ChangeOrderRequestBody implements RequestBody {
|
|||
private String orderStatus;
|
||||
private String remark;
|
||||
|
||||
private final HashSet<Pair<String, Integer>> oldSkuData;
|
||||
private HashSet<Triple<String, String, Integer>> oldSkuData;
|
||||
|
||||
private final HashSet<Pair<String, Integer>> newSkuData;
|
||||
private HashSet<Pair<String, Integer>> newSkuData;
|
||||
|
||||
private final static String DEFAULT_WAREHOUSE_NAME = "SZBA宝安仓";
|
||||
|
||||
|
@ -36,7 +37,25 @@ public class ChangeOrderRequestBody implements RequestBody {
|
|||
}
|
||||
}
|
||||
|
||||
public ChangeOrderRequestBody(String platformOrderId, String orderStatus, HashSet<Pair<String, Integer>> oldSkuData,
|
||||
public ChangeOrderRequestBody() {
|
||||
}
|
||||
|
||||
public static ChangeOrderRequestBody buildChangeOrderRequestBody(String platformOrderId, String orderStatus,
|
||||
HashSet<Pair<String, Integer>> oldSkuData,
|
||||
HashSet<Pair<String, Integer>> newSkuData, String remark) {
|
||||
ChangeOrderRequestBody body = new ChangeOrderRequestBody();
|
||||
body.platformOrderId = platformOrderId;
|
||||
body.orderStatus = orderStatus;
|
||||
body.oldSkuData = new HashSet<>();
|
||||
if (oldSkuData != null) {
|
||||
oldSkuData.forEach(pair -> body.oldSkuData.add(Triple.of(pair.getLeft(), null, pair.getRight())));
|
||||
}
|
||||
body.newSkuData = newSkuData;
|
||||
body.remark = remark;
|
||||
return body;
|
||||
}
|
||||
|
||||
public ChangeOrderRequestBody(String platformOrderId, String orderStatus, HashSet<Triple<String, String, Integer>> oldSkuData,
|
||||
HashSet<Pair<String, Integer>> newSkuData, String remark) {
|
||||
this.platformOrderId = platformOrderId;
|
||||
this.oldSkuData = oldSkuData;
|
||||
|
@ -58,17 +77,20 @@ public class ChangeOrderRequestBody implements RequestBody {
|
|||
putNonNull(json, "remark", remark);
|
||||
JSONArray stockDataArray = new JSONArray();
|
||||
if (oldSkuData != null && !oldSkuData.isEmpty()) {
|
||||
for (Pair<String, Integer> oldSkuDatum : oldSkuData) {
|
||||
for (Triple<String, String, Integer> oldSkuDatum : oldSkuData) {
|
||||
JSONObject stockData = new JSONObject();
|
||||
stockData.put("warehouseName", DEFAULT_WAREHOUSE_NAME);
|
||||
stockData.put("stockSku", oldSkuDatum.getKey());
|
||||
stockData.put("quantity", oldSkuDatum.getValue());
|
||||
stockData.put("stockSku", oldSkuDatum.getLeft());
|
||||
if (oldSkuDatum.getMiddle() != null) {
|
||||
stockData.put("erpOrderItemId", oldSkuDatum.getMiddle());
|
||||
}
|
||||
stockData.put("quantity", oldSkuDatum.getRight());
|
||||
stockData.put("type", OperationType.REMOVE.code);
|
||||
stockDataArray.add(stockData);
|
||||
}
|
||||
|
||||
}
|
||||
if(newSkuData != null) {
|
||||
if (newSkuData != null) {
|
||||
for (Pair<String, Integer> newSkuDatum : newSkuData) {
|
||||
JSONObject stockData = new JSONObject();
|
||||
stockData.put("warehouseName", DEFAULT_WAREHOUSE_NAME);
|
||||
|
@ -78,7 +100,7 @@ public class ChangeOrderRequestBody implements RequestBody {
|
|||
stockDataArray.add(stockData);
|
||||
}
|
||||
}
|
||||
putNonNull(json,"stockData", stockDataArray.toJSONString());
|
||||
putNonNull(json, "stockData", stockDataArray.toJSONString());
|
||||
return json;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,8 +123,8 @@ public class AddCardJob implements Job {
|
|||
// Still no card in order, add one
|
||||
HashSet<Pair<String, Integer>> card = new HashSet<>();
|
||||
card.add(Pair.of(CARD_SKU, 1));
|
||||
ChangeOrderRequestBody changeOrderRequestBody = new ChangeOrderRequestBody(mabangOrder.getPlatformOrderId(), null,
|
||||
null, card, null);
|
||||
ChangeOrderRequestBody changeOrderRequestBody = ChangeOrderRequestBody.buildChangeOrderRequestBody(
|
||||
mabangOrder.getPlatformOrderId(), null, null, card, null);
|
||||
changeOrderRequests.add(changeOrderRequestBody);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,232 @@
|
|||
package org.jeecg.modules.business.domain.job;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
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.*;
|
||||
import org.jeecg.modules.business.entity.GiftRule;
|
||||
import org.jeecg.modules.business.entity.PlatformOrder;
|
||||
import org.jeecg.modules.business.service.IGiftRulesService;
|
||||
import org.jeecg.modules.business.service.IPlatformOrderMabangService;
|
||||
import org.jeecg.modules.business.service.IPlatformOrderService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
|
||||
@Slf4j
|
||||
public class AddGiftJob implements Job {
|
||||
|
||||
private static final Integer DEFAULT_NUMBER_OF_DAYS = 30;
|
||||
|
||||
private static final List<String> DEFAULT_SHOPS = Arrays.asList("FC Takumiya", "FCFR");
|
||||
private static final Integer DEFAULT_NUMBER_OF_THREADS = 10;
|
||||
private static final String OBSOLETE_STATUS_CODE = "4";
|
||||
|
||||
@Autowired
|
||||
private IPlatformOrderService platformOrderService;
|
||||
@Autowired
|
||||
private IGiftRulesService giftRulesService;
|
||||
@Autowired
|
||||
private IPlatformOrderMabangService platformOrderMabangService;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
LocalDateTime endDateTime = LocalDateTime.now();
|
||||
LocalDateTime startDateTime = endDateTime.minusDays(DEFAULT_NUMBER_OF_DAYS);
|
||||
List<String> shops = DEFAULT_SHOPS;
|
||||
JobDataMap jobDataMap = context.getMergedJobDataMap();
|
||||
String parameter = ((String) jobDataMap.get("parameter"));
|
||||
if (parameter != null) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(parameter);
|
||||
if (!jsonObject.isNull("startDateTime")) {
|
||||
String startDateStr = jsonObject.getString("startDateTime");
|
||||
startDateTime = LocalDateTime.parse(startDateStr);
|
||||
}
|
||||
if (!jsonObject.isNull("endDateTime")) {
|
||||
String endDateStr = jsonObject.getString("endDateTime");
|
||||
endDateTime = LocalDateTime.parse(endDateStr);
|
||||
}
|
||||
if (!jsonObject.isNull("shops")) {
|
||||
JSONArray shopsArray = jsonObject.getJSONArray("shops");
|
||||
List<String> shopList = new ArrayList<>();
|
||||
for (int i = 0; i < shopsArray.length(); i++) {
|
||||
shopList.add(shopsArray.getString(i));
|
||||
}
|
||||
shops = shopList;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error("Error while parsing parameter as JSON, falling back to default parameters.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!endDateTime.isAfter(startDateTime)) {
|
||||
throw new RuntimeException("EndDateTime must be strictly greater than StartDateTime !");
|
||||
}
|
||||
|
||||
List<PlatformOrder> platformOrders = platformOrderService.fetchUninvoicedOrdersForShops(startDateTime, endDateTime, shops);
|
||||
List<String> platformOrderIds = platformOrders.stream().map(PlatformOrder::getPlatformOrderId).collect(Collectors.toList());
|
||||
List<List<String>> platformOrderIdLists = Lists.partition(platformOrderIds, 10);
|
||||
List<GiftRule> giftRules = giftRulesService.findGiftRulesByShopCode(shops);
|
||||
Map<String, Map<Boolean, List<GiftRule>>> rulesMap = giftRules.stream()
|
||||
.collect(groupingBy(GiftRule::getShopCode,
|
||||
groupingBy(GiftRule::getMatchQuantity)));
|
||||
Map<String, Set<String>> giftSetByShop = giftRules.stream()
|
||||
.collect(Collectors.groupingBy(GiftRule::getShopCode,
|
||||
Collector.of(HashSet::new, (s, rule) -> s.add(rule.getSku()), (s1, s2) -> {
|
||||
s1.addAll(s2);
|
||||
return s1;
|
||||
})));
|
||||
|
||||
List<OrderListRequestBody> requests = new ArrayList<>();
|
||||
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> ordersWithLogistic = new ArrayList<>();
|
||||
log.info("Constructing gift insertion requests");
|
||||
List<ChangeOrderRequestBody> giftInsertionRequests = constructGiftInsertionRequests(mabangOrders, rulesMap, giftSetByShop, ordersWithLogistic);
|
||||
log.info("{} gift insertion requests to be sent to MabangAPI", giftInsertionRequests.size());
|
||||
|
||||
log.info("Clearing logistic channel names before inserting gifts");
|
||||
platformOrderMabangService.clearLogisticChannel(ordersWithLogistic, executor);
|
||||
|
||||
List<CompletableFuture<Boolean>> giftInsertionFutures = giftInsertionRequests.stream()
|
||||
.map(giftInsertionRequestBody -> CompletableFuture.supplyAsync(() -> {
|
||||
boolean success = false;
|
||||
try {
|
||||
ChangeOrderRequest changeOrderRequest = new ChangeOrderRequest(giftInsertionRequestBody);
|
||||
ChangeOrderResponse response = changeOrderRequest.send();
|
||||
success = response.success();
|
||||
} catch (RuntimeException e) {
|
||||
log.error("Error communicating with MabangAPI", e);
|
||||
}
|
||||
return success;
|
||||
}, executor))
|
||||
.collect(Collectors.toList());
|
||||
results = giftInsertionFutures.stream().map(CompletableFuture::join).collect(Collectors.toList());
|
||||
nbSuccesses = results.stream().filter(b -> b).count();
|
||||
log.info("{}/{} gift insertion requests have succeeded.", nbSuccesses, giftInsertionRequests.size());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<ChangeOrderRequestBody> constructGiftInsertionRequests(List<Order> mabangOrders,
|
||||
Map<String, Map<Boolean, List<GiftRule>>> rulesMap,
|
||||
Map<String, Set<String>> giftSetByShop,
|
||||
List<Order> ordersWithLogistic) {
|
||||
List<ChangeOrderRequestBody> giftInsertionRequests = new ArrayList<>();
|
||||
Map<String, List<Order>> ordersByShop = mabangOrders.stream().collect(groupingBy(Order::getShopErpCode));
|
||||
// Go through orders by Shop
|
||||
for (Map.Entry<String, List<Order>> entry : ordersByShop.entrySet()) {
|
||||
String shopCode = entry.getKey();
|
||||
log.info("Going through orders from shop {}", shopCode);
|
||||
Map<Boolean, List<GiftRule>> rulesByType = rulesMap.get(shopCode);
|
||||
Set<String> giftSkuSet = giftSetByShop.get(shopCode);
|
||||
List<GiftRule> matchingQuantityRules = rulesByType.get(Boolean.TRUE);
|
||||
List<GiftRule> nonMatchingQuantityRules = rulesByType.get(Boolean.FALSE);
|
||||
|
||||
for (Order order : entry.getValue()) {
|
||||
log.info("Processing order {} ", order.getPlatformOrderId());
|
||||
// Non matching-quantity rules only apply once per order
|
||||
boolean nonMatchingRulesApplied = false;
|
||||
HashMap<String, Integer> newGiftMap = new HashMap<>();
|
||||
Map<Boolean, List<OrderItem>> orderItemMap = order.getOrderItems()
|
||||
.stream()
|
||||
.filter(orderItem -> !orderItem.getStatus().equalsIgnoreCase(OBSOLETE_STATUS_CODE))
|
||||
.collect(groupingBy(orderItem -> giftSkuSet.contains(orderItem.getErpCode())));
|
||||
for (OrderItem orderItem : orderItemMap.get(Boolean.FALSE)) {
|
||||
String erpCode = orderItem.getErpCode();
|
||||
if (!nonMatchingRulesApplied) {
|
||||
for (GiftRule giftRule : nonMatchingQuantityRules) {
|
||||
if (erpCode.matches(giftRule.getRegex())) {
|
||||
nonMatchingRulesApplied = true;
|
||||
putValueInMapOrReduce(giftRule.getSku(), 1, newGiftMap);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (GiftRule giftRule : matchingQuantityRules) {
|
||||
if (erpCode.matches(giftRule.getRegex())) {
|
||||
putValueInMapOrReduce(giftRule.getSku(), orderItem.getQuantity(), newGiftMap);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug("Order {} 's new gift map : ", newGiftMap);
|
||||
HashSet<Triple<String, String, Integer>> oldSkuData = new HashSet<>();
|
||||
HashMap<String, Integer> oldGiftMap = new HashMap<>();
|
||||
List<OrderItem> oldGifts = orderItemMap.get(Boolean.TRUE) == null ? new ArrayList<>() : orderItemMap.get(Boolean.TRUE);
|
||||
oldGifts.forEach(orderItem -> {
|
||||
oldSkuData.add(Triple.of(orderItem.getErpCode(),
|
||||
orderItem.getErpOrderItemId(), orderItem.getQuantity()));
|
||||
putValueInMapOrReduce(orderItem.getErpCode(), orderItem.getQuantity(), oldGiftMap);
|
||||
});
|
||||
HashSet<Pair<String, Integer>> newSkuData = new HashSet<>();
|
||||
newGiftMap.forEach((key, value) -> newSkuData.add(Pair.of(key, value)));
|
||||
|
||||
if (!newGiftMap.isEmpty() && !newGiftMap.equals(oldGiftMap)) {
|
||||
ChangeOrderRequestBody changeOrderRequestBody = new ChangeOrderRequestBody(order.getPlatformOrderId(), null,
|
||||
oldSkuData, newSkuData, null);
|
||||
giftInsertionRequests.add(changeOrderRequestBody);
|
||||
|
||||
// If the order already has a logistic channel name, then we need to clear it before inserting gifts
|
||||
if (order.getLogisticChannelName() != null && !order.getLogisticChannelName().isEmpty()) {
|
||||
ordersWithLogistic.add(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("Ended processing orders from shop {}", shopCode);
|
||||
}
|
||||
return giftInsertionRequests;
|
||||
}
|
||||
|
||||
private static void putValueInMapOrReduce(String key, Integer value, HashMap<String, Integer> giftMap) {
|
||||
if (giftMap.containsKey(key)) {
|
||||
giftMap.put(key, giftMap.get(key) + value);
|
||||
} else {
|
||||
giftMap.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -142,8 +142,8 @@ public class AddPortraitTubeJob implements Job {
|
|||
HashSet<Pair<String, Integer>> adequateTubes = currentAndAdequateTubes.getRight();
|
||||
// Do nothing if current tubes are the adequate tubes
|
||||
if (!currentTubes.containsAll(adequateTubes) || !adequateTubes.containsAll(currentTubes)) {
|
||||
ChangeOrderRequestBody changeOrderRequestBody = new ChangeOrderRequestBody(mabangOrder.getPlatformOrderId(), null,
|
||||
currentTubes, adequateTubes, null);
|
||||
ChangeOrderRequestBody changeOrderRequestBody = ChangeOrderRequestBody.buildChangeOrderRequestBody(
|
||||
mabangOrder.getPlatformOrderId(), null, currentTubes, adequateTubes, null);
|
||||
changeOrderRequests.add(changeOrderRequestBody);
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ public class AddPortraitTubeJob implements Job {
|
|||
if (canvasNew46RemainderCount > 0) {
|
||||
// TODO 2024-08-28 Temporarily use OLD 50cm tubes for NEW 46cm canvases
|
||||
tube50SingleCount++;
|
||||
} else if (canvas40RemainderCount > 0) {
|
||||
} else if (canvas40RemainderCount > 0 || canvasNew36RemainderCount > 0) {
|
||||
tube40SingleCount++;
|
||||
} else if (canvas30RemainderCount > 0){
|
||||
tube30SingleDoubleCount++;
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package org.jeecg.modules.business.domain.job;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.modules.business.entity.Sku;
|
||||
import org.jeecg.modules.business.service.ISkuService;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class SkuToCsvJob implements Job {
|
||||
|
||||
@Autowired
|
||||
private ISkuService skuService;
|
||||
|
||||
@Value("${jeecg.path.skuCsvPath}")
|
||||
private String FILE_PATH;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
log.info("SkuToCsv Job is running ...");
|
||||
List<Sku> skus = new ArrayList<>();
|
||||
Sku firstLine = new Sku();
|
||||
firstLine.setId("#");
|
||||
firstLine.setErpCode("erp_code");
|
||||
firstLine.setImageSource("image_source");
|
||||
skus.add(firstLine);
|
||||
skus.addAll(skuService.listImgUrls());
|
||||
List<String> csvLines = skus.stream()
|
||||
.map(sku -> String.format("%s,%s,%s", sku.getId(), sku.getErpCode(), sku.getImageSource())).collect(Collectors.toList());
|
||||
File csvFile = new File(FILE_PATH);
|
||||
|
||||
try (PrintWriter writer = new PrintWriter(csvFile)) {
|
||||
csvLines.forEach(writer::println);
|
||||
} catch (FileNotFoundException e) {
|
||||
log.error("Error writing to file", e);
|
||||
}
|
||||
log.info("SkuToCsv Job is done.");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.jeecg.modules.business.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GiftRule {
|
||||
|
||||
private final String shopCode;
|
||||
|
||||
private final String sku;
|
||||
|
||||
private final String regex;
|
||||
|
||||
private final Boolean matchQuantity;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.jeecg.modules.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.business.entity.GiftRule;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 添加赠品规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2024-09-02
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Repository
|
||||
public interface GiftRulesMapper extends BaseMapper<GiftRule> {
|
||||
|
||||
List<GiftRule> findByShop(List<String> shopCodes);
|
||||
}
|
|
@ -68,4 +68,6 @@ public interface SkuMapper extends BaseMapper<Sku> {
|
|||
List<SkuOrderPage> getInventoryByInvoiceNumber(@Param("invoiceNumber") String invoiceNumber);
|
||||
|
||||
List<Sku> listByClientId(@Param("clientId") String clientId);
|
||||
|
||||
List<Sku> listImgUrls();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.business.mapper.GiftRulesMapper">
|
||||
<select id="findByShop" resultType="org.jeecg.modules.business.entity.GiftRule">
|
||||
SELECT s.erp_code AS shop_code,
|
||||
sku.erp_code AS sku,
|
||||
g.normal_sku_regex AS regex,
|
||||
g.match_normal_sku_quantity AS match_quantity
|
||||
FROM gift_rules g JOIN shop s ON g.shop_id = s.id
|
||||
JOIN sku ON g.gift_sku_id = sku.id
|
||||
WHERE s.erp_code IN
|
||||
<foreach collection="shopCodes" separator="," open="(" close=")" item="shopCode">
|
||||
#{shopCode}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
|
@ -413,4 +413,11 @@
|
|||
JOIN product p ON s.product_id = p.id
|
||||
WHERE client_sku.client_id = #{clientId};
|
||||
</select>
|
||||
<select id="listImgUrls" resultType="org.jeecg.modules.business.entity.Sku">
|
||||
SELECT row_number() over (
|
||||
ORDER BY create_time DESC
|
||||
) as id, erp_code, image_source
|
||||
FROM sku
|
||||
WHERE image_source IS NOT NULL
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.jeecg.modules.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.business.entity.GiftRule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 添加赠品规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2024-09-02
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IGiftRulesService extends IService<GiftRule> {
|
||||
|
||||
List<GiftRule> findGiftRulesByShopCode(List<String> shopCodes);
|
||||
}
|
|
@ -104,4 +104,6 @@ public interface ISkuService extends IService<Sku> {
|
|||
void updateBatchStockByIds(List<Sku> skuToUpdate);
|
||||
List<SkuOrderPage> getInventoryByInvoiceNumber(String invoiceNumber);
|
||||
List<Sku> listByClientId(String clientId);
|
||||
|
||||
List<Sku> listImgUrls();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package org.jeecg.modules.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.modules.business.entity.GiftRule;
|
||||
import org.jeecg.modules.business.mapper.GiftRulesMapper;
|
||||
import org.jeecg.modules.business.service.IGiftRulesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 添加赠品规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2024-09-02
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class GiftRulesServiceImpl extends ServiceImpl<GiftRulesMapper, GiftRule> implements IGiftRulesService {
|
||||
|
||||
@Autowired
|
||||
private GiftRulesMapper giftRulesMapper;
|
||||
|
||||
public GiftRulesServiceImpl(GiftRulesMapper giftRulesMapper) {
|
||||
this.giftRulesMapper = giftRulesMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GiftRule> findGiftRulesByShopCode(List<String> shopCodes) {
|
||||
return giftRulesMapper.findByShop(shopCodes);
|
||||
}
|
||||
}
|
|
@ -480,4 +480,9 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
|||
return skuMapper.listByClientId(clientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Sku> listImgUrls() {
|
||||
return skuMapper.listImgUrls();
|
||||
}
|
||||
|
||||
}
|
|
@ -233,6 +233,8 @@ jeecg:
|
|||
shippingInvoiceDetailDir: /wia/invoices/shippingDetail
|
||||
shippingInvoicePdfDir: /wia/invoices/pdf/shipping
|
||||
shippingInvoiceDetailPdfDir: /wia/invoices/pdf/shippingDetail
|
||||
# sku csv file for image search
|
||||
skuCsvPath: /mnt/wia/products/sku.csv
|
||||
# CDG location
|
||||
CGS: /wia/files/WIASourcingCGCVF_mai.pdf
|
||||
#webapp文件路径
|
||||
|
|
Loading…
Reference in New Issue